Michael Kniskern
Michael Kniskern

Reputation: 25260

Google Cloud Messaging registration not returning "registration_id"

I am using the following tutorial to set up the Google Cloud Messaging in my Android application to push notifications:

http://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/android/remote_notifications_in_android/

When I try to register my application in the OnCreate method in the MainActivity class, it does not return a registration_id or error. It returns null for both.

Here is the code snippet from my application:

Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(Application.Context, 0, new Intent(), 0));
intent.PutExtra("sender", AndroidUserPreferences.GoogleCloudMessagingSenderId);
Application.Context.StartService(intent);

What do I need to check to get my application to register to receive Google Cloud Messaging notifications?

EDIT #1:

Under the Registering with Google Cloud Messaging section in the linked document, their is the following code snippet for retrieving the regsitration_id:

string registrationId = intent.GetStringExtra("registration_id"); 

I have not done anything with the HandleRegistration method yet because I have not gotten the registration process working yet.

Upvotes: 0

Views: 390

Answers (1)

Eran
Eran

Reputation: 393781

I have not done anything with the HandleRegistration method yet because I have not gotten the registration process working yet.

HandleRegistration is called when your app receives the registration response from GCM.

Therefore you are supposed to get the registration ID in HandleRegistration, so I'm not sure where you put the string registrationId = intent.GetStringExtra("registration_id"); line, but you probably put it in the wrong place.

Upvotes: 1

Related Questions