Adroid平台消息推送服务

来源:互联网 发布:小米5x网络制式 编辑:程序博客网 时间:2024/04/29 07:02

 

Android平台在起初并未提供消息推送服务,随着Android版本的推进,市场占有率的提升,对于这种服务器推送消息到设备的需求越来越高。在Android2.2发布的时候,在其API中公布了消息推送服务接口。自然,消息推送是需要服务器的,这个服务器自然顺理成章的由谷歌来提供,使用Gmail帐号鉴定唯一终端ID。其服务名称叫做C2DM(Android Cloud to Device Messaging),非常形象,云端到设备的消息。然而由于一些国内政策性因素,导致这项服务在国内并不稳定。这也给第三方软件公司提供了机会,一些厂商开始自己开发类似服务。以下总结三种类似服务:
1、C2DM(Android官方版本,基于XMPP)
  • It allows third-party application servers to send lightweight messages to their Android applications. The messaging service is not designed for sending a lot of user content via the messages. Rather, it should be used to tell the application that there is new data on the server, so that the application can fetch it.
  • C2DM makes no guarantees about delivery or the order of messages. So, for example, while you might use this feature to tell an instant messaging application that the user has new messages, you probably would not use it to pass the actual messages.
  • An application on an Android device doesn’t need to be running to receive messages. The system will wake up the application via Intent broadcast when the the message arrives, as long as the application is set up with the proper broadcast receiver and permissions.
  • It does not provide any built-in user interface or other handling for message data. C2DM simply passes raw message data received straight to the application, which has full control of how to handle it. For example, the application might post a notification, display a custom user interface, or silently sync data.
  • It requires devices running Android 2.2 or higher that also have the Market application installed. However, you are not limited to deploying your applications through Market.
  • It uses an existing connection for Google services. This requires users to set up their Google account on their mobile devices.
2、Android Push Notification(国内版本,基于XMPP)
  • 免费:在免费推送消息条数上限之内免费使用,超出部分需要为超出部分消息付费。(运营模式比较清晰,如果市场做的足够好,而且软件做的足够产品化,相信此版本会脱颖而出)
  • 部署容易:集成到已开发软件中非常容易,推送消息到软件非常简单,只需发送一个URL。无C2DM的各种限制,不需要Gmail账户。基于云平台的服务,不需要自己搭建推送服务器。
  • 效率:电量消耗及网络流量消耗极少,可以跟踪用户对你发送消息的互动情况。

3、APNS(Android Push Notification Service)(国内版本,技术实现比较简单,未验证)

  • 快速集成:提供一种比C2DM更加快捷的使用方式,避免各种限制.
  • 无需架设服务器:通过使用"云服务",减少额外服务器负担.
  • 可以同时推送消息到网站页面,android 手机
  • 耗电少,占用流量少.
总结:国内使用消息推送服务,若是个人开发者或者微型开发团队,建议使用上述第二种方案,若是具备一定规模以及用户群比较大的公司,建议自己开发实现,首选是依据XMPP进行二次开发部署。这样对于大企业来说更能开发出符合自己企业需求的消息推送方案,也比较容易维护后期扩展。(想腾讯的消息协议应该是比较高效的一种通信协议,可以适当研究实现)。
原创粉丝点击