php信鸽推送(针对token推送)
程序员文章站
2022-05-30 09:41:32
...
title//推送标题,content//推送内容 account//对应的用户token $type//自定义参数
$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;
}
先去信鸽官网申请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教程有兴趣的朋友有所帮助。
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频