We have recently discovered that some Google GCM API keys generated using our instructions before September 30 do not work for push. Using the old instructions, you will get a GCM API key, but will be unable to use it to send push notifications. This is a permanent change on Google’s part, documented at developers.google.com/cloud-messaging/http-server-ref#error-codes. Instructions for dealing with this change are below.

You can use curl to check your GCM API key. Send the following request:

curl --header "Authorization: key=REPLACE_WITH_GCM_API_KEY" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{"registration_ids":["ABC"]}"

(where REPLACE_WITH_GCM_API_KEY is your Google GCM API key). If you receive a response back that looks like this:

{"multicast_id":5464085859083008962,"success":0,"failure":1,"canonical_ids":0,"results": [{"error":"InvalidRegistration"}]}

then your GCM API key works fine, and you don’t need to do anything further.

On the other hand, if you receive following response:

<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

then your GCM API key will not work for push. If that is the case, you can use the following workaround:

1.1 Go to the GCM developer console (https://console.developers.google.com) and open the project that has the invalid GCM API key.
1.2 Click on the menu in the upper right (“Utilities and more”) and select “Project Settings”.
1.3 Save the project number – you will use it later.
1.4 Go to the FCM console (https://console.firebase.google.com).
1.5 Select “Import a Google project” to convert your project from a GCM to an FCM project.
1.6 Open the converted project and go to Project Settings.
1.7 Click on the “Cloud Messaging” tab.
1.8 Copy “Server Key” and “Sender Id” values. You will need these values to enable push notifications in your application. (“Sender Id” should be the same as project number from step 1.3.)

At this point, you can create a GCM app key with the correct Google API key. The way you do this will depend on which product you are using.

IBM Marketing Cloud

2.1 Log into the IMC console as you normally would.
2.2 Go to Development -> Apps
2.3 Create a new Google app key using “New app” or edit an existing Google app key.
2.4 Use the Web API key from step 1.8 above as the Google API key credential for the IMC app key.
2.5 Save the IMC app key – you will use it later.
2.6 On the client side in your Android application, edit MceConfig.json. Set the “senderId” value to the Google project number (from step 1.8). Set the “appKey” value (either “prod” or “dev” depending on what you set your app key to be) to the IMC app key (from step 2.5).

Xtify 2.x

2.1 Log into the Xtify console as you normally would.
2.2 Go to App Manager -> App Keys
2.3 Create a new Google app key using “Add New Application” or edit an existing Google app key.
2.4 Use the Web API key from step 1.8 above as the Google API key.
2.5 Save the Xtify app key – you will use it later.
2.6 On the client side In your Android application, replace PROJECT_NUM with the Google project number (from step 1.8). Replace XTIFY_APP_KEY (from step 2.5) with the Xtify app key.

Join The Discussion

Your email address will not be published. Required fields are marked *