Question

I need to get the registration Id for GCM push notification implementation? Since I am using the GoogleCloudMessaging class but I am not getting the ID.

Était-ce utile?

La solution

Use the GoogleCloudMessaging class with the register function sending your senderId that you got from the google developer Api console.

GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String regid = gcm.register(senderId);

Autres conseils

How to do this now can be found on https://developers.google.com/cloud-messaging/android/client

It boils down to creating a RegistrationIntentService and using this to receive the token. For refreshing the token you create an InstanceIDListenerService and to retrieve it in there and for the first time you start the RegistrationIntentService as follows:

Intent regIntent = new Intent(this, myRegistrationIntentService.class);
startService(regIntent);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top