Thursday, July 19, 2012

Dude - Where is my C2DM?

So a project we're working on at Technoracle requires push notifications.  For iOS builds we are using Apple's APNS, which is very secure and reliable.  I had an issue with C2DM and went to the Google Developer website and was blind sided by this message:

Dang!  For the uninitiated, C2DM is Cloud to Device Messaging.  Those little red notifications you see on your phone letting you know that you have actionable items to look at works by a small daemon running in the background at all times, waiting for messages.  The messages are composed of several logical parts but the basic message contains a section describing the application destination, then another about the message.

C2DM vs GCM?

So what is GCM and why is it better?  Google Cloud Messaging is built from the lessons learned from C2DM, or so it appears to us.  Like C2DM, it's main purpose is to transfer messages to Android powered devices to let them know there is a message on a server waiting for them to do something with.  C2DM was very lightweight and easy to implement.  GCM offers some improved options.  From the google GCM website:

"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."

We are excited to try it and look forward to this improvement.

More reading:

To learn more about GCM, you can join the android-gcm group and read the following documents: 

Getting Started  Read this document to learn the basic steps involved in developing Android applications based on GCM.

Architectural Overview Read this document for a description of the underlying concepts and architecture in GCM.

Demo App Tutorial Read this document to walk through setting up and running the GCM demo app.

Advanced Topics Read this document to get a more in-depth understanding of key GCM features.

Migration Read this document if you are a C2DM developer moving to GCM.

GCM also provides helper libraries for client and server development.