Search code examples
androidandroid-c2dm

How we get registration id from c2dm (Android)?


On Android applications, how to get Registration Id?


Solution

  • Here is a link to the C2DM page. http://code.google.com/android/c2dm/index.html#registering

    At the bottom of the page there are links to an example app which uses C2DM.

    Basically you need to declare a receiver to receive the registration_id from Google and then fire off a registration request like so:

    Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
    registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
    registrationIntent.putExtra("sender", emailOfSender);
    startService(registrationIntent);