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

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

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

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

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


当前回答

看看Xtify平台。看起来他们就是这么做的,

其他回答

They have their listeners which has to be used by you by using their library classes in your code. You need not to bother about pushing. You have to send the message to server server will push the message to the device. They use OAuth. Regarding Protocols, there are two methods using CCS and XMPP. CCS just uses XMPP as an authenticated transport layer, so you can use most XMPP libraries to manage the connection. To send notifications to device you can write code in android app to send as well as your server code. the message sending will be done only by your code. Rest will be taken care by Google Server in GCM case. You can check detail at this link

http://developer.android.com/google/gcm/server.html

还有安全问题

谷歌云消息安全https://groups.google.com/forum/#!主题/ android-gcm / M-EevBitbhQ

In case your app is not running then also devices can recieve notification because you have to write code for broadcast listeners. In background it will be listening to server and whenever any message packet will be there it will recieve the message as notification. Android has service you need to not to bother about it. You have only to use those resources using the library class that makes your work easier and let them write if your app is not running then also it recieve notification. Obviously, there would be some listener whick make the app to recieve.Check "Recieve the message" section in this link

http://developer.android.com/google/gcm/client.html

它还将接受用户的请求。对于GCM,这就可以了。请勾选“发送信息”

http://developer.android.com/google/gcm/client.html

我最近开始在Android上使用MQTT http://mqtt.org,作为一种实现您所要求的方式(即不是SMS,而是数据驱动,几乎是即时消息传递,可伸缩,而不是轮询等)。

我有一篇关于这方面的背景信息的博客文章http://dalelane.co.uk/blog/?p=938

(注意:MQTT是IBM的技术,我应该指出我为IBM工作。)

如果你可以依靠谷歌库来满足你的目标市场,那么你可能想要依靠GTalk的功能(在现有的用户名上注册一个资源-当消息进入BroadcastReceiver时拦截它)。

如果不能,而且我希望您不能,那么您就需要捆绑您自己的XMPP版本。这是一个痛苦的过程,但是如果XMPP单独捆绑成一个独立的库,就会容易一些。

你也可以考虑PubSubHubub,但我不知道它的网络使用情况。我相信它是构建在XMPP之上的。

XMPP是一个很好的解决方案。我在一个支持推送的、实时的Android应用程序中使用过它。XMPP功能强大,高度可扩展,易于集成和使用。

有很多免费的XMPP服务器(尽管出于礼貌,您不应该滥用它们),还有一些开源服务器可以在您自己的机器上运行。OpenFire是一个很好的选择。

你想要的库不是上面提到的Smack,而是aSmack。但是请注意,这是一个构建环境—您必须构建库。

以下是我对XMPP解决方案对电池寿命的影响进行的计算:

The Android client must maintain a persistent TCP connection by waking up periodically to send a heartbeat to the XMPP server. This clearly imposes a cost in terms of power usage. An estimate of this cost is provided below: Using a 1400mAh battery (as supplied in the Nexus One and HTC Desire) An idle device, connected to an 3G network, uses approximately 5mA The wake-up, heartbeat, sleep cycle occurs every 5 minutes, takes three seconds to complete and uses 300mA The cost in battery usage per hour is therefore: 36 seconds 300mA = 3mAh sending heartbeat 3600 seconds 5mA = 5mAh at idle 4:95 + 3 = 7:95mAh combined A 1400mAh battery lasts approximately 11.6 days at idle and 7.3 days when running the application, which represents an approximate 37% reduction in battery life. However, a reduction in battery life of 37% represents the absolute worst case in practice given that devices are rarely completely idle.

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