用户工具

站点工具


差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

toaster:android-developer-guide [2015/03/18 15:33]
cobub
toaster:android-developer-guide [2017/07/14 11:18]
行 1: 行 1:
-====== 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 (外部编辑)