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.

Was it helpful?

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);

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top