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

         目前厂商通道有华为、小米、魅族、海外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);

}

}

需要腾讯信鸽插件请联系企业即时通讯-触点通QQ:1417249367
代码下载:http://webrtc.qiyeim.com/xiazai/appcan_Demo.zip

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值