Android messaging mechanism – C2DM and GCM

One of the issues of using CLOUD is not of polling info – this we know to do using SOAP or REST on top of web servers etc.

But how do we know that we need to get data? One alternative is by polling on the Web service all the time asking if something changed. This is bad for few reasons:

  1. Usage of battery.
  2. Usage of bandwidth.
  3. Server resources (CPU, RAM)

Android provide us with a unique mechanism – C2DM! This is defined by google as:

Android Cloud to Device Messaging (C2DM) is a service that helps developers send data from servers to their applications on Android devices. The service provides a simple, lightweight mechanism that servers can use to tell mobile applications to contact the server directly, to fetch updated application or user data. The C2DM service handles all aspects of queueing of messages and delivery to the target application running on the target device.

You can find short explanation over here:

http://amsanjeev.wordpress.com/2011/09/19/an-introduction-to-c2dm-part-1/

http://amsanjeev.wordpress.com/2011/09/19/c2dm-workflow-explained/

 

This is also deprecated so now google recoomend GCM which is:

Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device.

http://developer.android.com/guide/google/gcm/index.html

And here is a simple tutorial:

http://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/

This entry was posted in android, servers, Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *