Friday, November 11, 2011

Android Cloud to Device Messaging(C2DM) Tutorial

                               Android Cloud to Device Messaging(C2DM) Tutorial  

This tutorial is for getting started with Android Cloud to Device Messaging (C2DM) on Android. In the iOS world it is knows as “push notifications”.

This feature will definitely help developers and their apps to streamline and optimize the data transfers. This would mean that apps now do not have to poll their servers at regular intervals to check for updates. The servers will be able to send updates (like Push Notifications) to the devices and makes it easier for mobile applications to sync data with servers.


There are many different ways of accomplishing the same thing(polling,constant server connections,SMS messages).

C2DM Alternatives:

Polling: The application itself would periodically poll your servers to check for new messages. You would need to implement everything from queuing messages to writing the polling code. Alerts are no good if they’re delayed due to a low polling period but the more frequently you poll, the more the battery is going to die.

SMS: Android can intercept SMS messages and you could include a payload to tell the application what to do. But then why not just use SMS in the first place? SMS is costly.

Persistent Connection: This would solve the problem of periodic polling but would destroy the battery life.
                                                   Cloud to device messaging   

“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.”

It is a server push service provided by Google so that 3rd party applications can push messages to their applications on android devices.
Here are a few basic things to know about C2DM:

    It requires Android 2.2; C2DM uses Google services which are present on any device running the Android Market.
    It uses existing connections for Google services. This requires the users to sign into their Google account on Android.
    It allows 3rd party servers to send lightweight data messages to their apps. The C2DM service is not designed for pushing a lot of user content; rather it should be used like a “tickle”, to tell the app that there is new data on the server, so the app can fetch it.
    An application doesn’t need to be running to receive data messages. The system will wake up the app via an Intent broadcast when the the data message arrives, so long as the app is set up with the proper Intent Receiver and permissions.
    No user interface is required for receiving the data messages. The app can post a notification (or display other UI) if it desires.




6 comments:

  1. thanks for this post...
    plz post the any example of C2DM with source code.


    thanks...

    ReplyDelete
  2. Thanks for ur post vijay......please provide one example for this.......

    Thanks,
    Rajshekar

    ReplyDelete
  3. hope this will help you.......firzan,raj alfresco............

    http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html#c2dm_overview

    ReplyDelete
  4. hi friends .. Now android c2dm is migrate to Gcm ... please refer Google cloud message in developer.android.com

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...