本文整理汇总了PHP中Message::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setTitle方法的具体用法?PHP Message::setTitle怎么用?PHP Message::setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::setTitle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasMethods
public function testHasMethods()
{
foreach ($this->messages as $message) {
$m = new Message();
$m->setMessage($message['message']);
$m->setPriority($message['priority']);
$this->assertFalse($m->hasTitle());
$this->assertFalse($m->hasUrl());
$this->assertFalse($m->hasUrlTitle());
$this->assertFalse($m->hasSound());
$this->assertFalse($m->hasHtml());
$this->assertFalse($m->hasDate());
}
foreach ($this->messages as $message) {
$m = new Message();
$m->setTitle($message['title']);
$m->setMessage($message['message']);
$m->setUrl($message['url']);
$m->setUrlTitle($message['url_title']);
$m->setPriority($message['priority']);
$m->setSound($message['sound']);
$m->setHtml($message['html']);
$m->setDate(new \DateTime($message['date']));
$this->assertTrue($m->hasTitle());
$this->assertTrue($m->hasUrl());
$this->assertTrue($m->hasUrlTitle());
$this->assertTrue($m->hasSound());
$this->assertTrue($m->hasHtml());
$this->assertTrue($m->hasDate());
}
}
示例2: send
/**
* 批量发送消息
* @return [type] [description]
*/
static function send($sendId)
{
$pushInfoModel = new PushInfoModel();
$db = DB::getInstance();
if (!empty($sendId)) {
$andSql = "and a.id={$sendId}";
}
$sql = "select b.device_token,b.device_type,b.token, a.params, a.id, a.content from t_push_info a, t_login b where a.to_user = b.uid and b.device_token != '' and a.is_send = 0 {$andSql} and b.token not like 'expired at%' group by device_token";
$infos = $db->get_all($sql);
if (count($infos > 0)) {
foreach ($infos as $info) {
if ($info['device_type']) {
$push = new XingeApp(2200102180, "661fd033916fadbf4e0866a18978782a");
$mess = new MessageIOS();
$mess->setAlert($info['content']);
$params = json_decode($info['params'], true);
if (!empty($params['content'])) {
$params['content'] = urldecode($params['content']);
}
$mess->setCustom($params);
$raw = $push->PushSingleDevice($info['device_token'], $mess, XingeApp::IOSENV_PROD);
$ret = json_encode($raw, true);
if ($ret['ret_code'] == 0) {
$sql = "update t_push_info set is_send = 1 where id={$info['id']}";
$db->query($sql);
}
} else {
// for android
$push = new XingeApp(2100117084, "13391a7ec8a47d5e30525a04bd04befa");
$mess = new Message();
$mess->setTitle('合租吧');
$mess->setContent($info['content']);
$params = json_decode($info['params'], true);
if (!empty($params['content'])) {
$params['content'] = urldecode($params['content']);
}
$mess->setCustom($params);
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setStyle(new Style(0, 1, 1, 0, 0));
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_ACTIVITY);
$mess->setAction($action);
$raw = $push->PushSingleDevice($info['device_token'], $mess);
//$raw = XingeApp::PushTokenAndroid(2100117084, "13391a7ec8a47d5e30525a04bd04befa", "标题", "大家好!", $info['device_token']);
var_dump($raw);
$ret = json_encode($raw, true);
if ($ret['ret_code'] == 0) {
$sql = "update t_push_info set is_send = 1 where id={$info['id']}";
$db->query($sql);
}
}
}
}
}
示例3: testSetTitle
/**
* Tests Message->setTitle()
*/
public function testSetTitle()
{
$this->Message->setTitle('title');
$this->assertEquals('title', $this->Message->title);
}
示例4: pushMessage
/**
* 推送接口
* @param int $push_type 1单个设备 2部分人(*常用)
* @param int $device_type 设备类型 1:浏览器设备 2:pc设备 3:Android设备 4:ios设备 5:windows phone设备
* @param string $title 标题(仅安卓)
* @param string $content 留言正文
* @param int $customtype 自定义类型,t
* @param string $customvalue 自定义值,v
* @param string $p_deviceTokens 用户推送ID,百度里是buserid
* @param string $tag_name 指定标签
* @return array results
*/
public static function pushMessage($push_type, $device_type, $title = '', $content, $customtype = null, $customvalue = null, $p_deviceTokens = null, $tag_name = null)
{
$push = null;
$mess = null;
$push = static::getPush($device_type);
if ($push == null) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '推送对象获取失败,无法创建推送任务。');
}
if ($device_type == 4) {
$mess = new MessageIOS();
$mess->setExpireTime(86400);
//$mess->setSendTime("2014-03-13 16:00:00");
$mess->setAlert($content);
//$mess->setAlert(array('key1'=>'value1'));
$mess->setBadge(0);
$mess->setSound('');
if (isset($customtype, $customvalue)) {
$custom = array('t' => intval($customtype), 'v' => $customvalue);
$mess->setCustom($custom);
}
} else {
if ($device_type == 3) {
$mess = new Message();
if ($title == '') {
$title = $content;
}
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setTitle($title);
$mess->setContent($content);
$mess->setExpireTime(86400);
//$style = new Style(0);
#含义:样式编号0,响铃,震动,不可从通知栏清除,不影响先前通知
$style = new Style(0, 1, 1, 0, 0);
$mess->setStyle($style);
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_ACTIVITY);
$action->setActivity(' ');
//扯淡的xinge sdk,isValid()方法判断m_activity默认值有点问题
$mess->setAction($action);
if (isset($customtype, $customvalue)) {
$custom = array('t' => intval($customtype), 'v' => $customvalue);
$mess->setCustom($custom);
}
} else {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '请传入正确的设备类型,iOS 还是 安卓');
}
}
$params['production_mode'] = static::$DEPLOY_STATUS == 2;
//是否正式环境
$ret = array();
switch ($push_type) {
case 1:
//指定token
$p_deviceTokens = is_array($p_deviceTokens) ? $p_deviceTokens : explode(',', $p_deviceTokens);
if (count($p_deviceTokens) == 0 || count($p_deviceTokens) == 1 && $p_deviceTokens[0] == null) {
return Utility::getArrayForResults(RUNTIME_CODE_ERROR_PARAM, '请传入正确的用户推送token');
}
if (count($p_deviceTokens) > 5) {
$retMulti = $push->CreateMultipush($mess, $device_type == 3 ? 0 : (static::$DEPLOY_STATUS == 2 ? XingeApp::IOSENV_PROD : XingeApp::IOSENV_DEV));
$ret[] = array('action' => 'CreateMultipush', 'ret' => $retMulti);
if (is_array($retMulti) && array_key_exists('result', $retMulti) && array_key_exists('push_id', $retMulti['result'])) {
$maxCount = 1000;
//每次最大传输设备量
for ($i = 0; $i < count($p_deviceTokens); $i += $maxCount) {
$ret[] = array('action' => 'PushDeviceListMultiple', 'token' => $p_deviceTokens, 'ret' => $push->PushDeviceListMultiple($retMulti['result']['push_id'], array_slice($p_deviceTokens, $i, $maxCount)));
}
}
} else {
foreach ($p_deviceTokens as $token) {
if ($device_type == 4) {
$ret[] = array('action' => 'PushSingleDevice', 'token' => $token, 'ret' => $push->PushSingleDevice($token, $mess, static::$DEPLOY_STATUS == 2 ? XingeApp::IOSENV_PROD : XingeApp::IOSENV_DEV));
} else {
if ($device_type == 3) {
$ret[] = array('action' => 'PushSingleDevice', 'token' => $token, 'ret' => $push->PushSingleDevice($token, $mess));
}
}
}
}
break;
case 2:
//指定设备群发
if ($device_type == 4) {
$ret[] = array('action' => 'PushAllDevices', 'token' => '0', 'ret' => $push->PushAllDevices(0, $mess, static::$DEPLOY_STATUS == 2 ? XingeApp::IOSENV_PROD : XingeApp::IOSENV_DEV));
} else {
if ($device_type == 3) {
$ret[] = array('action' => 'PushAllDevices', 'token' => '0', 'ret' => $push->PushAllDevices(0, $mess));
}
}
//.........这里部分代码省略.........
示例5: push_notice
private function push_notice($type)
{
$id = intval($this->input['id']);
if ($type == 'update' && !$id) {
$this->errorOutput('id不存在');
}
$app_id = intval($this->input['app_push_id']);
if (!$app_id) {
$this->errorOutput('请选择应用');
}
/**************权限控制开始**************/
//节点权限
if ($app_id && $this->user['group_type'] > MAX_ADMIN_TYPE) {
$nodes['nodes'][$app_id] = $app_id;
}
$nodes['_action'] = 'notice_manage';
$this->verify_content_prms($nodes);
/**************权限控制结束**************/
$content = trim($this->input['content']);
if (!$content) {
$this->errorOutput('请输入通知内容');
}
$ios = $ios_dev = '';
if ($this->input['ios'] == 1) {
$ios_dev = 1;
} else {
if ($this->input['ios'] == 2) {
$ios = 1;
}
}
$android_sys = $this->input['android'];
$winphone = $this->input['winphone'];
if (!$ios && !$ios_dev && !$android_sys && !$winphone) {
$this->errorOutput('请选择客户端设备系统');
}
//根据应用id查询注册应用信息
$sql = 'SELECT * FROM ' . DB_PREFIX . "app_info WHERE id = " . $app_id;
$appinfo = array();
$appinfo = $this->db->query_first($sql);
if (empty($appinfo)) {
$this->errorOutput('注册应用信息不存在');
}
//扩展字段
if ($this->input['extras']) {
$extras = $this->input['extras'];
}
//通知离线时间
$expire_time = intval($this->input['expire_time']);
//发送时间
$send_time = $this->input['send_time'];
//platform_type:1信鸽,2极光,3AVOS
$platform_type = $appinfo['platform_type'];
//极光可以不写标题,不写标题,默认显示应用包名称
$title = trim($this->input['title']);
if (!$title && $platform_type == 1) {
$this->errorOutput('请输入通知标题');
}
if ($platform_type == 1) {
$accessId = $appinfo['access_id'];
$secretKey = $appinfo['secret_key'];
//$accessId = 2100033914;
//$secretKey = '755776a7f60242ed472848ddf6b08197';
if (!$accessId || !$secretKey) {
$this->errorOutput('请传入应用信息');
}
include_once CUR_CONF_PATH . 'lib/XingeApp.php';
$push = new XingeApp($accessId, $secretKey);
$mess = new Message();
$mess->setTitle($title);
$mess->setContent($content);
//0是通知,1是消息
$mess_type = intval($this->input['mess_type']);
if ($mess_type) {
$mess->setType(Message::TYPE_MESSAGE);
} else {
$mess->setType(Message::TYPE_NOTIFICATION);
$style = new Style(0);
#含义:样式编号0,响铃,震动,可从通知栏清除,不影响先前通知
$style = new Style(0, 1, 1, 1, 0);
$mess->setStyle($style);
#接收消息时间范围
$acceptTime1 = new TimeInterval(0, 0, 23, 59);
$mess->addAcceptTime($acceptTime1);
//发送时间
if ($send_time) {
$send_time .= ':00';
$mess->setSendTime($send_time);
}
//离线时间
if ($expire_time) {
$mess->setExpireTime($expireTime);
}
$action = new ClickAction();
$action_type = intval($this->input['action_type']);
//点击通知操作
$action_url = $this->input['action_url'];
//打开的url地址
$intent = $this->input['intent'];
if (!$action_type) {
#打开activity或app本身
//.........这里部分代码省略.........
示例6: message_submit
function message_submit()
{
// get global user object
global $user;
// protect from unauthorized access
if (!isset($user) || !isset($_POST['formMessageSubmit']) || !isset($_POST['formMessage'])) {
logout();
die;
}
// get message data from $_POST
$title = filter_input(INPUT_POST, 'messageTitle');
$text = filter_input(INPUT_POST, 'messageText');
$time_now = date("Y-m-d H:i:s");
// send mail
send_mail($title, $text);
// set message object
$message = new Message();
$message->setIsActive(1);
$message->setCreatedOn($time_now);
$message->setLastEditedOn($time_now);
$message->setUser($user->getId());
$message->setTitle($title);
$message->setText($text);
// store message object in db
$message->store_in_db();
// set message cookie
$cookie_key = 'msg';
$cookie_value = 'Благодарим Ви за съобщението!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('location:' . ROOT_DIR . '?page=survey_role');
}
示例7: PushTagAndroid
/**
* 使用默认设置推送消息给标签选中设备android版
*/
public static function PushTagAndroid($accessId, $secretKey, $title, $content, $tag)
{
$push = new XingeApp($accessId, $secretKey);
$mess = new Message();
$mess->setTitle($title);
$mess->setContent($content);
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setStyle(new Style(0, 1, 1, 1, 0));
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_ACTIVITY);
$mess->setAction($action);
$ret = $push->PushTags(0, array(0 => $tag), 'OR', $mess);
return $ret;
}
示例8: DemoPushDeviceListMultipleNotification
function DemoPushDeviceListMultipleNotification()
{
$push = new XingeApp(00, 'secret_key');
$mess = new Message();
$mess->setExpireTime(86400);
$mess->setTitle('title');
$mess->setContent('content');
$mess->setType(Message::TYPE_NOTIFICATION);
$ret = $push->CreateMultipush($mess, XingeApp::IOSENV_DEV);
if (!($ret['ret_code'] === 0)) {
return $ret;
} else {
$result = array();
$deviceList1 = array('token1', 'token2', 'token3');
array_push($result, $push->PushDeviceListMultiple($ret['result']['push_id'], $deviceList1));
$deviceList2 = array('token4', 'token5', 'token6');
array_push($result, $push->PushDeviceListMultiple($ret['result']['push_id'], $deviceList2));
return $result;
}
}
示例9: show
public function show()
{
//如果应用在推送平台添加,需要传入应用id,然后根据应用id查询应用的密钥
$app_push_id = intval($this->input['app_id']);
if ($app_push_id) {
$sql = 'SELECT * FROM ' . DB_PREFIX . "app_info WHERE id = " . $app_push_id;
$appinfo = $this->db->query_first($sql);
}
if (!$appinfo['access_id'] || !$appinfo['access_key']) {
$this->errorOutput('缺少应用配置');
}
$content = trim($this->input['content']);
if (!$content) {
$this->errorOutput('缺少通知内容');
}
//platform_type:1信鸽,2极光,3AVOS
$platform_type = $appinfo['platform_type'];
//极光可以不写标题,不写标题,默认显示应用包名称
$title = trim($this->input['title']);
if (!$title && ($platform_type = 1)) {
$this->errorOutput('请输入通知标题');
}
//通知离线时间
$expire_time = intval($this->input['expire_time']);
//发送时间
$send_time = $this->input['send_time'];
//扩展字段
if ($this->input['extras']) {
$extras = $this->input['extras'];
}
$ios = $ios_dev = '';
if ($this->input['ios'] == 1) {
$ios_dev = 1;
} else {
if ($this->input['ios'] == 2) {
$ios = 1;
}
}
$android_sys = $this->input['android'];
$winphone = $this->input['winphone'];
if (!$ios && !$ios_dev && !$android_sys && !$winphone) {
$this->errorOutput('请选择客户端设备系统');
}
if ($platform_type == 1) {
$accessId = $appinfo['access_id'];
$secretKey = $appinfo['access_key'];
//$accessId = 2100033914;
//$secretKey = '755776a7f60242ed472848ddf6b08197';
if (!$accessId || !$secretKey) {
$this->errorOutput('请传入应用信息');
}
include_once CUR_CONF_PATH . 'lib/XingeApp.php';
$push = new XingeApp($accessId, $secretKey);
$mess = new Message();
$mess->setTitle($title);
$mess->setContent($content);
//0是通知,1是消息
$mess_type = intval($this->input['mess_type']);
if ($mess_type) {
$mess->setType(Message::TYPE_MESSAGE);
} else {
$mess->setType(Message::TYPE_NOTIFICATION);
$style = new Style(0);
#含义:样式编号0,响铃,震动,可从通知栏清除,不影响先前通知
$style = new Style(0, 1, 1, 1, 0);
$mess->setStyle($style);
#接收消息时间范围
$acceptTime1 = new TimeInterval(0, 0, 23, 59);
$mess->addAcceptTime($acceptTime1);
$action = new ClickAction();
$action_type = intval($this->input['action_type']);
//点击通知操作
$action_url = $this->input['action_url'];
//打开的url地址
if (!$action_type) {
#打开activity或app本身
$action->setActionType(ClickAction::TYPE_ACTIVITY);
} else {
if ($action_type == 1 && $action_url) {
//打开链接
$action->setActionType(ClickAction::TYPE_URL);
$action->setUrl($action_url);
#打开url需要用户确认
$action_comfirm = intval($this->input['action_comfirm']);
$action->setComfirmOnUrl($action_comfirm);
} else {
if ($action_type == 2) {
$intent = $this->input['intent'];
$action->setActionType(ClickAction::TYPE_INTENT);
$action->setIntent($intent);
}
}
}
$mess->setAction($action);
#自定义内容
if ($extras) {
$mess->setCustom($extras);
}
}
//设备标识
//.........这里部分代码省略.........
示例10: DemoPushTags
function DemoPushTags()
{
$push = new XingeApp(00, 'secret_key');
$mess = new Message();
$mess->setTitle('title');
$mess->setContent('content');
$mess->setType(Message::TYPE_MESSAGE);
$tagList = array('Demo3');
$ret = $push->PushTags(XingeApp::DEVICE_ANDROID, $tagList, 'OR', $mess);
return $ret;
}
示例11: pushOrderInfo
/**
* 更改订单状态时,向手机端(包括Android和IOS)发送提醒信息
*
* @param [object] $[shop] [店铺对象]
* @param [object] $[mainOrder] [主订单]
* @param [int] $[toBeStatus] [要改变状态]
*
* @return Response
*/
protected function pushOrderInfo($shop, $mainOrder, $toBeStatus)
{
//获取信鸽系统配置
$accessId = Config::get('xinge.accessId');
$secretKey = Config::get('xinge.secretKey');
$xingeApp = new XingeApp($accessId, $secretKey);
//根据mainorder中的userid获取token和设备类型
$userTokens = UserToken::where('wy_user_id', $mainOrder->wy_user_id)->where('wy_user_type', USER_TYPE_1)->where('wy_status', LOGIN_STATUS_1)->get();
if (!empty($userTokens->toArray())) {
foreach ($userTokens as $index => $userToken) {
if (DEVICE_TYPE_1 == $userToken->wy_device_type) {
//根据不同状态获取不同的模板信息
switch ($toBeStatus) {
case ORDER_STATE_2:
//接单
$orderMessage = Config::get('xinge.androidRecvMessage');
break;
case ORDER_STATE_3:
//配送中
$orderMessage = Config::get('xinge.androidDeliveryMessage');
break;
case ORDER_STATE_4:
//完成
$orderMessage = Config::get('xinge.androidFinishMessage');
break;
case ORDER_STATE_6:
//拒单
$orderMessage = Config::get('xinge.androidRefuseMessage');
break;
default:
break;
}
if (isset($orderMessage)) {
//单击动作
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_ACTIVITY);
$action->setActivity($orderMessage['activity']);
//显示样式
$styleParams = $orderMessage['style'];
$style = new Style($styleParams['builderId'], $styleParams['ring'], $styleParams['vibrate'], $styleParams['clearable'], $styleParams['nId'], $styleParams['lights'], $styleParams['iconType'], $styleParams['styleId']);
//Android平台的消息
$message = new Message();
$message->setTitle($orderMessage['title']);
$message->setContent($orderMessage['content']);
$message->setExpireTime($orderMessage['expireTime']);
$message->setType(Message::TYPE_NOTIFICATION);
$message->setStyle($style);
$message->setAction($action);
} else {
$context = array("errorCode" => -10054, "userID" => $mainOrder->wy_user_id, "toBeStatus" => $toBeStatus);
Log::error(Lang::get('errormessages.-10054'), $context);
}
} elseif (DEVICE_TYPE_2 == $userToken->wy_device_type) {
//根据不同状态获取不同的模板信息
switch ($toBeStatus) {
case ORDER_STATE_2:
//接单
$orderMessage = Config::get('xinge.iosRecvMessage');
break;
case ORDER_STATE_3:
//配送中
$orderMessage = Config::get('xinge.iosDeliveryMessage');
break;
case ORDER_STATE_4:
//完成
$orderMessage = Config::get('xinge.iosFinishMessage');
break;
case ORDER_STATE_6:
//拒单
$orderMessage = Config::get('xinge.iosRefuseMessage');
break;
default:
break;
}
if (isset($orderMessage)) {
//IOS平台的消息,需要IOS文档
$message = new MessageIOS();
$message->setTitle($orderMessage['title']);
} else {
$context = array("errorCode" => -10055, "userID" => $mainOrder->wy_user_id, "toBeStatus" => $toBeStatus);
Log::error(Lang::get('errormessages.-10055'), $context);
}
} else {
$context = array("errorCode" => -10056, "userID" => $mainOrder->wy_user_id, "deviceType" => $userToken->wy_device_type);
Log::error(Lang::get('errormessages.-10056'), $context);
}
//自定义参数,key-value形式的
if (isset($message)) {
$custom = array('shop_name' => $shop->wy_shop_name, 'main_order_id' => $mainOrder->wy_main_order_id);
$message->setCustom($custom);
$result = $xingeApp->PushSingleDevice($userToken->wy_token, $message);
//.........这里部分代码省略.........