How Does Push Notification Technology Work on Android

How does push notification technology work on Android?

From what I've heard during an Android developers conference in Israel:

There is simply a TCP socket waiting in accept mode on a cloud Google server. The TCP connection had been initiated by the Google Play application. That's why Google Play must be installed on the device for making Google Cloud Messaging (GCM) (formerly Android Cloud to Device Messaging Service - C2DM) work.

When this TCP client socket receives some message, the message contains information such as the package name of the application it should be addressed to, and of course - the data itself. This data is parsed and packed into an intent that is broadcast and eventually received by the application.

The TCP socket stays open even when the device's radio state turns into "idle" mode. Applications don't have to be running to receive the intents.

More information at http://developer.android.com/google/gcm/gcm.html

Working principles of Android Push Notification System (how does push notification works in Android?)

Answering the question about how GCM service contacts the client, the GCM client contacts GCM to create the connection. You are correct that device addresses change as the device disconnects and reconnects so GCM cannot initiate the connection from the server side.

This connection is maintained as much as possible and is not created for specific messages.

The registration id identifies the device and app and allows GCM to route the message to the device, if it is connected. If it is not connected, GCM needs to wait until the device reconnects.

How does a push notification system works like on Y! Mail app?

There already is another question discussing how to implement push notification without the cloud to device messaging in older system.

There are several frameworks that give you push abillity. They all require a running a small background thread that is polling a server at a very short interval(Bad for data rate and battery) or keep an open connection to a server that is kept alive somehow and the client is notified every time a new message is waiting on the server.

Have a look at the question and maybe choose on of the mentioned frameworks, the frameworks will reuse the same service for all applications that are installed on the phone using the same framework and therefore save battery and general system usage.

How does device receive Android GCM push notification?

About the CGM there are a lot of informations on the Android Developers center.
The device keeps a connection open to the CGM (I think IP). If there is no connection between the server and the device, the CGM will store the incoming messages to deliver them later.

The iOS push technology keeps an IP connection open between the APNS (Apple Push Notification Service) and the device (cf: wiki). So it could be sensibly the same thing as the GCM.



Related Topics



Leave a reply



Submit