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?
3 Answers
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.
-
how do you determine what they are using C2MD , can you please elaborate , because C2MD is also using XMPP protocol then why whatsapp wont use their own service rather then using C2MD ? – Hunt Jun 04 '14 at 05:54
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 .

- 3,168
- 6
- 33
- 52
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:
- Poll a remote server every X seconds and check for new notifications (this is the more expensive choice).
- Run a background service, maintain a connection with a remote server, which will pump me any notifications that are to be received (sort of my like my own push notification implementation).

- 3,846
- 26
- 29
-
-
-
I think something has to be done in the server side like storing the state and notification to storage when the target device is off. – angelokh May 01 '11 at 21:55
-
got it. the server will 'cache' the notifications until its able to deliver them. optionally you could implement a 'expiration date' fro notifications as well. so when someone sends a notification it will say 'this notification is valid for 4 hours' the server will then try to deliver it within 4 hours and if it can't the notification will be deleted...etc. – thekindofme May 02 '11 at 00:34