Pergunta

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.

Foi útil?

Solução

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

Outras dicas

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top