user241242
user241242

Reputation: 33

how to get regid from GCM?

  1. I have an Android phone. How can I get regid from GCM?
  2. Is the regid unique to each application and instance?
  3. I got regid on the emulator and the application is working well!! How to install to an Android phone and get regid for communication?
  4. But iIs there a way to retrieve the registration IDs from my app directly via GCM? E. g. when I've got my app in the play store, how do I get the IDs of devices that downloaded my app?

Upvotes: 1

Views: 302

Answers (2)

manish jain
manish jain

Reputation: 620

  1. You register to GCM via the GoogleCloudMessaging.register() method.
  2. After that GCM callback give you registraion id

eg.

@Override
protected void onRegistered(Context context, String registrationId) {

    Log.e("regid",registrationId);

}

Upvotes: 0

Eran
Eran

Reputation: 393966

  1. You register to GCM via the GoogleCloudMessaging.register() method.
  2. Yes, the Registration ID is unique for each instance of your app, and different apps on the same device will have different Registration IDs.
  3. The same code that gave you the Registration ID on the emulator would give you a Registration ID on a real device.
  4. Each instance of your app gets its Registration ID from GCM (by registering to GCM when it's first launched). Then your app should send that Registration ID to your server. This is done outside of the GCM mechanism (you can send an HTTP request to your server that contains the Registration ID).

Upvotes: 2

Related Questions