如何在Android 2.1中实现Beluga或WhatsApp之类的消息系统
我正在尝试在我的 Android 应用程序中开发一个消息应用程序。该消息将像 Whatsapp 和 beluga 一样。我用谷歌搜索了一下,发现 C2DM Android 2.2 可以将推送通知发送到设备。然而,这在 Android 2.1 上不可用。有人知道 2.1 设备的 Whatsapp 如何发送通知吗?
I am trying to develop a message app within my android app. The message will be like whatsapp and beluga. I googled it and found C2DM Android 2.2 can send the push notifications to the device. However, this is not available on Android 2.1. Anyone knows how whatsapp send the notifications for 2.1 devices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 Android:Whatsapp 是基于 C2DM 构建的,当应用程序打开时,它会打开与其服务的 XMPP 连接以立即传递消息。他们还可能使用 MQTT 作为协议来最大限度地减少电池使用。基本上就是这样。
编辑:我了解到更多,Facebook 在他们的消息应用程序中使用 MQTT。 Whatsapp 基于 XMPP 构建,并具有自己的扩展。他们的服务器端运行在 ejabbard(erlang 中的 XMPP 实现)之上。 http://www.ejabberd.im/
在 2.1 之前的设备上,WhatsApp 可能会与其 XMPP 保持开放连接服务器在后台运行,但这对电池寿命来说并不是很好。
For Android: Whatsapp is build upon C2DM and when the app opens it opens an XMPP connection to their service to deliver the messages instantly. They also might use MQTT as a protocol to minimize battery usage. That's basically it.
Edit: I learned more, Facebook uses MQTT in their messaging app. Whatsapp is build upon XMPP with their own extensions. Their server side runs on top of ejabbard (XMPP implementation in erlang). http://www.ejabberd.im/
On pre 2.1 devices WhatsApp probably keeps a connection open to their XMPP servers in the background but this is not really good for battery life.
C2DM 现已被 GCM(Google 云消息传递) 取代。您可以使用它向您的应用程序发送通知。对于消息交换
,如果您想熟悉 GCM, 则应该依赖 xmpp (whatsapp)、mqtt(facebook Messenger)、mtproto (telegram) 等协议。尝试 appsrox 提供的本教程 - 使用 Google Cloud Messaging (GCM) 创建即时消息应用
他们也使用 GCM 进行消息传递。它不适合生产,但对于想要开发即时消息 Android 应用程序的人来说,它是一个极好的资源。
C2DM is replaced by GCM (google cloud messaging) now . you can use it for delivering the notifications to your app . For the exchange of message one should rely on protocols like xmpp (whatsapp), mqtt(facebook messenger), mtproto (telegram) etc.
if you are looking to familiarize yourself with GCM . try out this tutorial by appsrox - Create an Instant Messaging app using Google Cloud Messaging (GCM)
they are using GCM for the message delivery as well. it won't suit for production, but its an excellent resource for people who want to develop an instant messaging android app .
我不知道whatsapp到底使用了什么技术。但是,如果我要在不支持操作系统推送通知的情况下实现通知,我可以做两件事:
I don't know what exact technology is used in whatsapp. However, if i am to implement notifications where there is no support for push notifications from the OS, i can do two things: