阅读更多

http://bigcat.easymorse.com/?p=1210

 

 

 

参考http://code.google.com/intl/zh-CN/android/c2dm/index.html#intro android2.2以上支持,支持第三方应用程序的push。实现令人心动的消息push,GMail就是这么实现的,收信的速度比网页还快。 Components: 1,移动设备:必须运行android,并且安装Market,至少有一个登录的google账号。(Google坑爹啊) 2,自己的服务器:自己的服务器 3,C2DM服务器:google的服务器 授权机制: 1,Sender ID:一个google账号,用于标示开发者的身份,比如my-app@google.com 2,Application ID:Manifest.xml里面的pacakage name。用于标示应用程序 3,Registration ID:当应用程序向C2DM服务器注册时,C2DM服务器会返回这个ID,当应用程序获得这个ID之后,应该告诉自己的服务器,自己的服务器把这个ID存在数据库里面,用于告诉C2DM服务器标示客户端。 4,Google User Account:要使用C2DM服务,必须有一个google账号,再骂一次,坑爹啊GG。 5,Sender Auth Token:自己的服务器与C2DM服务器通信的认证。 应用程序发送Intent,com.google.android.c2dm.intent.REGISTER,附上自己的SenderID和AppId,就可以向C2DM服务器进行注册,注册成功之后,可以收到REGISTRATION Intent,获得Registration ID,这个Registration ID是会被C2DM改变的,所以这个REGISTRATION Intent可能会收到多次,要记得存储和发送给自己的服务器。 Here is the sequence of events that occurs when the application server sends a message: 1,The application server sends a message to C2DM servers. 2,Google enqueues and stores the message in case the device is inactive. 3,When the device is online, Google sends the message to the device. 4,On the device, the system broadcasts the message to the specified application via Intent broadcast with proper permissions, so that only the targeted application gets the message. This wakes the application up. 5,The application does not need to be running beforehand to receive the message.The application processes the message. If the application is doing non-trivial processing, you may want to grab a wake lock and do any processing in a Service. An application can unregister C2DM if it no longer wants to receive messages. This is the sequence of events that occurs when an Android application running on a mobile device receives a message: 1,The system receives the incoming message and extracts the raw key/value pairs from the message payload. 2,The system passes the key/value pairs to the targeted Android application in a com.google.android.c2dm.intent.RECEIVE Intent as a set of extras. 3,The Android application extracts the raw data from the RECEIVE Intent by key and processes the data.

更多相关文章

  1. 关于Android(安卓)Studio3.2新建项目Android(安卓)resource link
  2. Android(安卓)- Manifest 文件 详解
  3. Android之应用程序基础
  4. Android四大组件的理解
  5. Android官方入门文档[1]创建一个Android项目
  6. 第三章 Android程序设计基础
  7. android手机客户端上传文件,java servlet服务器端接收并保存到服
  8. Android(安卓)Studio 3.0开始android Device Monitor弃用
  9. 使用uiautomatorviewer和uiautomator来做android的UI测试

随机推荐

  1. android里getView,inflate,listview问题
  2. android ksoap用法
  3. Android(安卓)中Intent的putExtra()方法
  4. android,总结,判断应用程序是否切换到后
  5. android 获取当前时间
  6. android C/C++ source files 全局宏定义
  7. Android 之 setContentView 源码阅读
  8. android 调用系统相机程序,存放文件夹创建
  9. Android聊天软件开发(基于网易云IM即时通
  10. Android requestFeature() must be calle