Creating your Android GCM Credentials

This article covers the steps needed to setup the Google Console to provide credentials for Google Cloud Messaging (GCM).

To create a Google API project:

  1. Open the Google APIs Console page.
  2. If you haven't created an API project yet, this page will prompt you to do so:


Note: If you already have existing projects, the first page you see will be the Dashboard page. By clicking on the Create Project in the upper left hand corner


  1. Click Create project. Which will popup a window prompting you for your Project Name and Project ID. 


  1. After clicking on Create you will be redirected to your Project page. You will see something similar to the image below. Take note of the Project Number this is your GCM Sender ID that will be used later on.


Enabling the GCM Service

To enable the GCM service:

  1. In the main Google APIs Console page, select APIs & auth.
  2. Turn the Google Cloud Messaging for Android toggle to ON.

  3. Turn the Google Play Android Developer API toggle to ON.

  4. Turn the Google Play Game Services toggle to ON.

Make sure your Enabled APIs looks similar to the image below:

Obtaining an API Key

To obtain an API key:

  • In the main Google APIs Console page, select APIs & Auth -> Credentials. You will see a screen that resembles the following:


  • Click Create new key. Which will pop-up the following box. Pick a server key.


  • Always make sure to leave the box blank. Do not add IPs or Android SHA 1 Hashes as this can cause Unauthorized Errors.


  • Click Create:


Take note of the API key value as you will need to enter it into our platform.  Click here for instructions where to enter the API key:

Adding a Google API Key to Enable Google Cloud Messaging

Now you are ready to implement the Apmetrix code needed to handle Push Notifications.

Android GCM Code Example

You should validate your API Key with the following curl call

curl --header "Authorization: key=API_KEY" --header CType:"application/json"  -d "{\"registration_ids\":[\"ABC\"]}"

This curl call will either return back:

For a valid key:{"multicast_id":6481164306343226213,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} 

If you API Key is invalid you will receive:

<H2>Error 401</H2>

Note: If you need to rotate the key, click Generate new key. A new key will be created while the old one will still be active for up to 24 hours. If you want to get rid of the old key immediately (for example, if you feel it was compromised), click Delete key


Have more questions? Submit a request