Google Cloud Messaging is a very useful service, which incidentally is free, from Google. This service allows developers to transmit data from their servers to their apps on various Android powered devices. This message is essentially a lightweight message that will alert the Android application of the presence of new data on the server. The application will then bring up that fresh data for the consumption of the end user. Google Cloud Messaging or GCM as it is known replaces the beta version of Android Cloud to Device Messaging Framework which is also known C2DM. C2DM was discontinued in June 2012, giving way to GCM.
Migration from C2DM to GCM means that the end user is moving from an old generation technology to next generation technology. It would be relevant to dwell a bit on the differences between GCM and C2DM. GCM replaces C2DM and delivers easier use and better battery efficiency. Even though it has been built on the platform of C2DM, GCM differs in a few important ways. One of the primary notes of difference is that GCM supports multicast messages. This means that one message can be sent to multiple devices at the same time. Similarly, GCM can support multiple partners in sending messages to the same application.
GCM enables applications in using something called “message with payload” that can help deliver messages of upto 4 Kb and GCM can also go upto 100 messages in terms of storage. The one major point to be noted here is that both these systems are not interoperable. The transition has to be made from C2DM to GCM. During migration, the server will discern between the new GCM registration ID and a C2DM id. It is strongly recommended to migrate to GCM and it is a rather simple process of migration of apps from C2DM to GCM.
There are two aspects of change to help this migration process along. One of the client changes and the other the server changes. Client changes will begin with replacing the email account which was passed in the sender parameter of the registration intent which has the project number. This project number will be created when during the signing up for the new GCM service. This will result in the generation of a response from GCM. This registration ID should then be sent to the application server. During this stage care must be taken to ensure that the server knows that it is a GCM registration ID and not a C2DM registration ID.
Now comes the changes that the server must go through. The client changes result in the application server receiving a GCM registration ID. The server will then store this registration ID and distinguish it from any existing C2DM IDs. Thereafter, sending any messages to GCM enabled devices needs to be sent to a new endpoint, namely https://android.googleapis.com/gcm/send. The other change takes place with the API key replacing the ClientLoginAuth token. This API key is also generated during the process of signing up. The API key should be included in the Authorization header of the request.