触点客服开发文档应用中心

咨询热线400-8075-114

您现在的位置:主页 > 聚焦我们 > 行业资讯 > >腾讯信鸽推送(一):服务端架构

腾讯信鸽推送(一):服务端架构

来源:admin发布日期2019-02-14 19:53浏览:

         目前厂商通道有华为、小米、魅族、海外FCM,oppp需要邀请才能集成,vivo目前只支持几个大厂集成,例如腾讯,阿里巴巴。oppo,vivo目前还处于内测当中。当时找过极光、个推,他们虽然支持厂商通道集成,但必须要成为他们的VIP才支持该功能。而腾讯信鸽集成厂商通道是免费的。于是我的计划是苹果手机就用个推,华为、小米、魅族、海外FCM用腾讯信鸽推送,安卓其他的手机用极光推送。等oppo,vivo厂商通道内测好了,再把这2个品牌加入到腾讯信鸽推送。目前在中国市场占有率排在前5名是华为、小米、oppp、vivo、苹果,其他品牌比如锤子、360手机市场占有率小,他们也懒得做厂商通道。
        服务端采用php来推送,因为php使用的范围比较广。不说了,先贴代码。
push.php

<?php
 
header("Content-Type: text/html; charset=utf-8");
define ( "__ROOT__", $_SERVER ['DOCUMENT_ROOT'] );
require_once (__ROOT__ . "/vendor/xinge/index.php");
require_once (__ROOT__ . "/vendor/jpush/jpush/index.php");
 
pushMessage();
 
function pushMessage()
{
$Registration_Id = $_POST["Registration_Id"];
$FcName = $_POST["FcName"];
$MessengText = $_POST["MessengText"];
$sublen=strlen($Registration_Id);
if($sublen==40) DemoPushSingleDeviceNotification($Registration_Id,1,$FcName,$MessengText);//添加元素
else JPushDeviceListMultipleNotification($Registration_Id,1,$FcName,$MessengText,$_POST["Tel1"]);//添加元素
}
?>

xinge
require_once ('XingeApp.php');
//单个设备下发通知消息
function DemoPushSingleDeviceNotification($CID,$PlatForm,$FcName,$UserText)
{
$push = new XingeApp(2104563460, '01536b093fafb86bbe92b8095582692f');
$mess = new Message();
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setTitle($FcName);
$mess->setContent($UserText);
$mess->setExpireTime(86400);
//$style = new Style(0);
#含义:样式编号0,响铃,震动,不可从通知栏清除,不影响先前通知
$style = new Style(0,1,1,0,0);
$action = new ClickAction();
$action->setActionType(ClickAction::TYPE_URL);
$action->setUrl("http://www.qiyeim.com");
#打开url需要用户确认
$action->setComfirmOnUrl(1);
$custom = array('key1'=>'value1', 'key2'=>'value2');
$mess->setStyle($style);
$mess->setAction($action);
$mess->setCustom($custom);
$acceptTime1 = new TimeInterval(0, 0, 23, 59);
$mess->addAcceptTime($acceptTime1);
$ret = $push->PushSingleDevice($CID, $mess);
return($ret);
}
//大批量下发给设备 android
//iOS 请构建MessageIOS 消息
function DemoPushDeviceListMultipleNotification($deviceList,$PlatForm,$FcName,$UserText)
{
$push = new XingeApp(2104563460, '01536b093fafb86bbe92b8095582692f');
$mess = new Message();
$mess->setType(Message::TYPE_NOTIFICATION);
$mess->setExpireTime(86400);
$mess->setTitle($FcName);
$mess->setContent($UserText);
$mess->setType(Message::TYPE_NOTIFICATION);
$ret = $push->CreateMultipush($mess);
if (!($ret['ret_code'] === 0))
return $ret;
else
{
$result=array();
array_push($result, $push->PushDeviceListMultiple($ret['result']['push_id'], $deviceList));
return ($result);
}
}
代码下载:http://webrtc.qiyeim.com/xiazai/appcan_Demo.zip

【本文标签】:

热点新闻/ hot news

关闭试用申请

关闭资料下载申请

触点即时通-书生

二维码 返回顶部 微信扫一扫,关注IT行业,聚焦即时通讯;