user1840829
user1840829

Reputation: 61

Where do I put the app id for GCM?

Below is the how to from google to register for GCM. Where in the second line of code do I put my appid? Comme to think about it is the appid the name of my project on the Google App Engine?

sender is the ID of the account authorized to send messages to the application, typically the email address of an account set up by the application's developer. app is the application's ID, set with a PendingIntent to allow the registration service to extract application information. For example:

Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender", "[email protected]");
startService(registrationIntent);

Upvotes: 0

Views: 670

Answers (2)

Eran
Eran

Reputation: 393771

The code in your quote is partly wrong. The value of sender used to be an email address (in the now deprecated C2DM), but in GCM the sender should contain the Google API Project ID.

sender is the project number of the account authorized to send messages to the Android application.

app is the Android application's ID, set with a PendingIntent to allow the registration service to extract Android application information.

Upvotes: 1

Jorge Cevallos
Jorge Cevallos

Reputation: 3678

According to http://developer.android.com/google/gcm/gcm.html

app is the Android application's ID, set with a PendingIntent to allow the registration service to extract Android application information.

GCM extracts your app ID from the pending intent you are passing. So your second line is as it should be.

But I recommend you to use the gcm.jar library instead. It makes handling GCM much easier: Add gcm.jar in Eclipse IDE (Google Cloud Messaging)

Upvotes: 0

Related Questions