跳至内容
Cobub文档中心
用户工具
登录
站点工具
工具
显示页面
修订记录
反向链接
媒体管理器
网站地图
登录
媒体管理器
网站地图
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
~~Title:Cobub Toaster android开发者指南 - 开源移动应用运营平台 - 移动统计、移动推送解决方案 - Cobub 移动开发者中心~~ {{description>Cobub Toaster android开发者指南}} {{keywords>Cobub Toaster,开源移动应用分析,移动分析,移动应用分析,android,开发者指南}} ====== Android开发者指南 ====== 版本支持 * 兼容Android2.2以上(API 8以上) * SDK版本v1.0 ===== 集成步骤 ===== 修改**AndroidManifest.xml** 添加权限 <code> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/></code> 添加组件 <code> <service android:name="com.cobub.toaster.push.component.PushService"> <intent-filter> <action android:name="com.cobub.toaster.push.SYNC" /> </intent-filter> </service> <receiver android:name="com.cobub.toaster.push.component.CPushReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> </code> **添加代码** 在APP启动以后尽早调用: <code> CPushInterface.initPushService(Context ctx, String UID, String host, int port);</code> ===== API参考说明 ===== **初始化** <code> CPushInterface.initPushService(Context ctx, String UID, String host, int port);</code> ctx:上下文参数 UID:必须传入UID host:推送服务器绑定的域名或IP地址 port:推送服务器绑定的端口 **设置Channel** 此方法为终端设备设定TAG值 <code> CPushInterface.setChannel(Context ctx, String channelName);</code> ctx:上下文参数 channelName:channel的值,这里即为为终端设置TAG,例如“location:Beijing” **已阅反馈** 向推送服务器PNS报告通知栏消息已被点击。 <code> CPushInterface.sendReadFeedback(Context context, String mid, String expired);</code> ctx:上下文参数 mid:推送消息中的mid expired:推送消息中的expired时间 **接收推送** 透传消息采用Broadcast传递,需要自定义一个BroadcastReceiver来接收,Receiver需要过滤自身app包名(package)的action,否则无法收到消息,如下内容需加入menifest: <code> <receiver android:name="com.cobub.toaster.push.TestReceiver" android:permission="com.cobub.toaster.push"> <intent-filter > <action android:name="com.cobub.toaster.push"/> </intent-filter> </receiver></code> 从推送服务器推送到手机的消息包含如下内容: <code> mid:“XXXXXX” data:“XXXXXX” expired:“XXXXXX” channel:“XXXXXXXX” </code> 在Receiver中可以通过以下方式取出字段: <code> String msg = intent.getStringExtra("data"); String expired = intent.getStringExtra("expired"); String mid = intent.getStringExtra("mid");</code> 可根据需要调用已阅反馈接口。
toaster/android-developer-guide.txt
· 最后更改: 2017/07/14 11:18 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部