An Introduction to C2DM
What is C2DM
C2DM stands for Cloud to Device Messaging. It is a service provided by Google to allow Android developers to send data from third party servers to Android devices. The intention here is not to use it as a mechanism to share large amounts of data, but to share the occurrence of server events and some meta data to the Android device.
Need for C2DM
Currently most applications are modelled on client server architecture to restrict the use of system resources on the device side. Heavy use of system resources one the mobile device can ultimately affect the user experience which is an extremely important criteria in mobile devices.
The need to communicate server events to the client efficiently is required for most use cases . Prior to C2DM, the common approach for such a requirement has been to write a service that would poll the server regularly to check if there is any new event and execute applications logic accordingly . C2DM eliminates the need to have component running the client application by providing a mechanism by which the server can communicate asynchronously back to the client.
C2DM is not intended to be used as data channel between the server and the client. The recommended practice is to inform the device about the event at the server and so that the device can take appropriate client actions eg. sync data with the server. This avoids the need to write a service that keeps polling the server, ultimately reducing the system resource usage.
How it works
For detailed explaination, visit C2DM Workflow Explained
- Android 2.2 or above.
- App Server should have internet connectivity.
- Notification requirements are not beyond the available quotas.
Advantages of C2DM
- Better usage of system resources like device battery.
- Less stress on the servers compared to polling approach.
- No background process per application required on the device.
Limitations of C2DM
- Limited message size of 1024 bytes.
- Best effort delivery ( msg delivery not guaranteed
- No support for TTLS
- Requires server to have internet access.
- Quotas for day and hour.
Custom implementations of push notifications should be developed if you have one or more of the following limitations.
- App server with no internet connectivity.
- SLA requirements
- Require priority of messages
- Require guaranteed message delivery.
Information on how to build your custom push notification infrastructure is beyond the scope of this article and will be explained in detail in a different post.
Applications with C2DM effectively integrated can leverage the Google infrastructure to provide the user with a better user experience. And the best part is that you do not have to pay to use this service unlike alternatives like SMS.
Hope all of you found this article informative. In case you require more information please feel free to contact me .