当前位置:Gxlcms > PHP教程 > php信鸽推送(针对token推送)

php信鸽推送(针对token推送)

时间:2021-07-01 10:21:17 帮助过:3人阅读

title//推送标题,content//推送内容 account//对应的用户token $type//自定义参数

先去信鸽官网申请key,然后接入key并且引用XingeApp.php(官网有提供) 因为以下的方法是基于XingeApp的开发的

protected function PushAccoun($title, $content, $account, $type) {

$pushAndroid = new XingeApp(88888, '888888');
$pushIOS = new XingeApp(888888, '888888);
$mess = new Message();
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setTitle($title);
$mess->setContent($content);
$mess->setExpireTime(0);
// $style = new Style(0);
#含义:样式编号0,响铃,震动,不可从通知栏清除,不影响先前通知
$style = new Style(0, 1, 1, 1, 0);
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_ACTIVITY);
#打开url需要用户确认
// $action->setComfirmOnUrl(0);
$mess->setStyle($style);
$mess->setAction($action);
$mess->setCustom(array('id' => "", 'title' => "", 'type' => $type));
$messios = new MessageIOS();
$messios->setExpireTime(0);
$messios->setAlert($content);
$messios->setBadge(1);
$messios->setSound("");
$messios->setCustom(array('id' => "", 'title' => "", 'content' => $content, 'type' => $type));
$acceptTime1 = new TimeInterval(0, 0, 23, 59);
$mess->addAcceptTime($acceptTime1);
$ret = $pushAndroid->PushSingleAccount(0, $account, $mess);
$ret1 = $pushIOS->PushSingleAccount(0, $account, $messios, XingeApp::IOSENV_DEV);
$ret = array($ret, $ret1);
return $ret;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了php信鸽推送(针对token推送),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行