php信鴿推送(針對token推送)

來源:互聯網
上載者:User
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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.