android push机制-C2DM

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值