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

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

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

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

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


当前回答

谷歌最近(2016年5月18日)宣布Firebase现在是移动开发者的统一平台,包括接近实时的推送通知。它也是多平台的:

该公司现在为所有Firebase用户提供免费和无限的服务 支持iOS、Android和Web的通知。

其他回答

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

GCM的问题是在这个过程中涉及到很多配置:

你必须在Android应用中添加大量样板文件 需要配置外部服务器与GCM服务器通信 您必须编写测试

如果你喜欢简单的东西(像我一样),你应该试试UrbanAirship。这是(恕我直言)在应用程序中使用GCM的最简单方法,无需进行大量配置。它还提供了一个漂亮的GUI来测试是否正确地传递了GCM消息。

你可以在这里找到文档和入门指南 您可以在这里找到一个示例应用程序

注:我没有附属城市飞艇在任何方式

谷歌最近(2016年5月18日)宣布Firebase现在是移动开发者的统一平台,包括接近实时的推送通知。它也是多平台的:

该公司现在为所有Firebase用户提供免费和无限的服务 支持iOS、Android和Web的通知。

我找不到我在哪里读到它,但我相信gmail利用一个开放的TCP连接来执行电子邮件推送。

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.

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