我最近了解到iPhone应用程序能够接收几乎即时的通知。

这是以推送通知的形式提供的,这是一种定制的协议,可以保持与iPhone的数据连接,并向应用程序发送二进制数据包,它会以极快的速度弹出警报,从服务器应用程序发送到手机应用程序的响应时间为0.5 - 5秒。这是作为数据而不是SMS发送的,以非常非常小的数据包作为数据计划的一部分收费,而不是作为传入消息。

我想知道,如果,使用Android,有一个类似的设施,或者是否有可能实现接近这个使用Android api的东西。为了澄清,我将相似定义为:

不是短信,而是一些数据驱动的解决方案 尽可能的实时 是否可扩展,即作为移动应用程序的服务器部分,我可以在几秒钟内通知数千个应用程序实例

我欣赏的应用程序可以拉基于,HTTP请求/响应风格,但理想情况下,我不想轮询那么严重,只是为了检查通知;除此之外,它就像滴漏数据计划。


当前回答

我最近开发了http://pushdroid.org,它是一个单一的应用程序,应该安装在手机上,就像谷歌已经在2.2中实现了它,从1.5开始工作,并通过意图广播。

其他回答

我一直在研究这个问题,jamesh推荐的PubSubHubBub不是一个选项。PubSubHubBub用于服务器到服务器的通信

"I'm behind a NAT. Can I subscribe to a Hub? The hub can't connect to me." /Anonymous No, PSHB is a server-to-server protocol. If you're behind NAT, you're not really a server. While we've kicked around ideas for optional PSHB extensions to do hanging gets ("long polling") and/or messagebox polling for such clients, it's not in the core spec. The core spec is server-to-server only. /Brad Fitzpatrick, San Francisco, CA Source: http://moderator.appspot.com/#15/e=43e1a&t=426ac&f=b0c2d (direct link not possible)

我得出的结论是,最简单的方法是使用Comet HTTP push。这是一个简单且易于理解的解决方案,但它也可以用于web应用程序。

As GTalk is gone from the SDK, it might be a good idea to make a 'standard' push messaging system. That way, only one service has to run, only one extra tcp connection needs to be open. Applications should talk to this service using Intents and should first request permission to send and receive notification from the service. The service should then notify the user a new application wants to send and receive messages. The user will then grant or deny permission, so he stays in control. The application will then register an action + category to the service, so the service knows how to deliver the pushed message.

这到底是不是一个好主意?

谷歌正在贬低C2DM,但他们引入了GCM(谷歌云消息),我认为他们没有任何配额,而且是免费的!不过它确实需要Android 2.2+ !http://developer.android.com/guide/google/gcm/index.html

Firebase Cloud Messaging FCM FAQ是GCM的新版本。它继承了GCM的核心基础设施,可以在Android、iOS和Chrome上可靠地传递消息。但是他们会继续支持GCM,因为现在很多开发者都在使用GCM sdk来处理通知,而客户端应用的升级需要时间。

截至2012年6月26日,谷歌云消息传递是向设备上运行的应用程序发送消息的首选方式。

以前(现在已弃用),该服务被称为“云到设备消息”。

Why dont you go with the XMPP implementation. right now there are so many public servers available including gtalk, jabber, citadel etc. For Android there is one SDK is also available named as SMACK. This we cant say a push notification but using the XMPP you can keep a connection open between client and server which will allow a two way communication. Means Android client and server both can communicate to each other. At present this will fulfill the need of Push in android. I have implemented a sample code and it really works great