Search code examples
androidandroid-c2dm

Getting a unique RegistrationID of a Android device to C2DM


To use C2DM for my application i registered new Gmail account with Google as a Sender account.
Now i am confused that how to get RegistrationID for my device and how to associate it with the Sender account. i want to install this application on multiple Andorid phones so do i need unique RegistrationID for each Android phone .


Solution

  • There are two sides to C2DM:

    1. Your server stores registration IDs for the users. It requests n auth code from Google's servers (using ClientLogin) and then uses that auth code to send push messages.

    2. Your Android app requests a registration ID from Google's servers. It is sent one over C2DM. It sends it to the server, to be stored there (so messages can be sent to it).

    This tutorial describes it all in detail, with code:

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

    A registration ID is like the address on a postal envelope - it describes where a push message is to be sent, the destination. So yes, you need one for each device. Registration IDs are actually assigned to a specific app (name space) on a specific device.