Anton
Anton

Reputation: 941

Migration from C2DM to GCM

I reading this, but I don't understand what I must do. Now my application doing registration in c2dm by this code:

String pushId =  C2DMessaging.getRegistrationId(this);
if(pushId == "")
{
    C2DMessaging.register(this, "[email protected]");
}

What I must change in this code to do migration from c2dm to gcm?

Upvotes: 2

Views: 2373

Answers (3)

azgolfer
azgolfer

Reputation: 15137

First, go through the Getting Started steps. Once you created an API project, you will receive a 'Project ID', as mentioned #4 item on that document:

Take note of the value after #project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID.

So you just need to change your code to:

C2DMessaging.register(this, "4815162342");

The senderID must be a string number.

I am using the example from the 'Getting Started' guide, you should replace the sender ID with your own Project ID.

Finally, go through the GCM Architectural Overview, as you need to make some changes to the server for all of these to work.

Upvotes: 3

Piyush Agarwal
Piyush Agarwal

Reputation: 25858

In GCM to get rid from Qutota google removed the signup an activation of an email for using Google Cloud Service.

When you go to Google Developer Console Here and click on create a new project that will give you a new project id that will be present in URL.

The PROJECT ID here will work like a user name and one more thing, this time Google is providing a jar gcm.jar that you need to add in your project classpath using build path to make GCM work .

this jar contains a class named GCMRegistrar having predefined function register() so you just need to add this code and forget

final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
  GCMRegistrar.register(this, SENDER_ID);
} else {
  Log.v(TAG, "Already registered");
}

In C2DM SENDER_ID : Activated Gmail ID.

In GCM SENDER_ID : PROJECT ID in url .

Upvotes: 0

Raz
Raz

Reputation: 9058

What you need to change is basically the email address. You need to send instead the API Key which you received in Google APIs Console page.

Upvotes: 1

Related Questions