質問

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.

役に立ちましたか?

解決

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

他のヒント

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);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top