Search code examples
androidandroid-c2dmgoogle-cloud-messaging

Migration from C2DM to GCM


I reading this, but I don't understand what I must do. Now my application doing registration in c2dm by this code:

String pushId =  C2DMessaging.getRegistrationId(this);
if(pushId == "")
{
    C2DMessaging.register(this, "email@gmail.com");
}

What I must change in this code to do migration from c2dm to gcm?


Solution

  • First, go through the Getting Started steps. Once you created an API project, you will receive a 'Project ID', as mentioned #4 item on that document:

    Take note of the value after #project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID.
    

    So you just need to change your code to:

    C2DMessaging.register(this, "4815162342");
    

    The senderID must be a string number.

    I am using the example from the 'Getting Started' guide, you should replace the sender ID with your own Project ID.

    Finally, go through the GCM Architectural Overview, as you need to make some changes to the server for all of these to work.