龙空技术网

爱码哥|消息推送开发指南

爱码哥 334

前言:

眼前兄弟们对“androidphp推送消息”大体比较关注,各位老铁们都想要了解一些“androidphp推送消息”的相关内容。那么小编也在网上搜集了一些对于“androidphp推送消息””的相关知识,希望兄弟们能喜欢,兄弟们一起来了解一下吧!

极光推送

JPush是经过考验的大规模APP推送平台,每天推送消息数超过5亿条。 开发者集成SDK后,可以通过调用API推送消息。同时,JPush提供可视化的web端控制台发送通知,统计分析推送效果。

官网地址:

插件代码:ImagJPush

支持平台:Android,iOS

打包参数:App Key: 从极光推送网站后台获取的App Key

方法

示例代码

上传Registration ID

$page.onload = function() {

var jPush = $phone.plugin('ImagJPush');

var registrationIdUrl = '' + jPush.getRegistrationId();

$http.get(registrationIdUrl);

}

说明:用getRegistrationId()方法获取Registration ID,上传Registration ID到自己的服务器。

用Registration ID推送消息

在服务启端用Registration ID通过Rest API或者Java, PHP, C#推送消息。

具体参考极光推送文档:

百度推送

百度云推送是免费专业最精准的移动推送平台,为Android和iOS的APP提供免费推送SDK下载,,支持百亿级的消息推送,秒级触达移动用户,有效的提高留存率,提升产品用户体验。

官网地址:

插件代码:ImagBaiduPush

支持平台:仅Android

打包参数:API Key: 从百度推送网站后台获取的API Key

方法

示例代码

上传Channel ID

$page.onload = function() {

var baiduPush = $phone.plugin('ImagBaiduPush');

var channelIdUrl = '' + baiduPush.getChannelId();

$http.get(channelIdUrl);

}

说明:用getChannelId()方法获取channel ID,上传channel ID到自己的服务器。

用Channel ID推送消息

// 4. 设置请求参数,创建请求实例

PushMsgToSingleDeviceRequest request = new PushMsgToSingleDeviceRequest().

addChannelId("xxxxxxxxxxxxxxxxxx").

addMsgExpires(new Integer(3600)). //设置消息的有效时间,单位秒,默认3600*5.

addMessageType(1). //设置消息类型,0表示透传消息,1表示通知,默认为0.

add("{\"title\":\"TEST\",\"description\":\"Hello Baidu push!\"}").

addDeviceType(3); //设置设备类型,deviceType => 1 for web, 2 for pc,

//3 for android, 4 for ios, 5 for wp.

// 5. 执行Http请求

PushMsgToSingleDeviceResponse response = pushClient.pushMsgToSingleDevice(request);

说明:在服务器端用channel ID通过REST API或者Java, PHP, C#等推送消息。

具体参考百度推送文档:

标签: #androidphp推送消息