This document tells you how to get started setting up a Google Cloud Messaging (GCM) implementation. Before you begin, make sure to set up the Google Play Services SDK. You need this SDK to use the GCM APIs.
Creating a Google API project
To create a Google API project:
- Open the Google Developers Console.
- If you haven't created an API project yet, click Create Project.
- Supply a project name and click Create.
Once the project has been created, a page appears that displays your project ID and project number. For example, Project Number: 670330094152.
- Copy down your project number. You will use it later on as the GCM sender ID.
Enabling the GCM Service
To enable the GCM service:
- In the sidebar on the left, select APIs & auth.
- In the displayed list of APIs, turn the Google Cloud Messaging for Android toggle to ON.
Obtaining an API Key
To obtain an API key:
- In the sidebar on the left, select APIs & auth > Credentials.
- Under Public API access, click Create new key.
- In the Create a new key dialog, click Server key.
- In the resulting configuration dialog, supply your server's IP address. For testing
purposes, you can use
- Click Create.
- In the refreshed page, copy the API key. You will need the API key later on to perform authentication in your app server.
Note: If you need to rotate the key, click Regenerate key. A new key will be created. If you think the key has been compromised and you want to delete it immediately, click Delete.
Once you've finished the tasks listed above, you're ready to start implementing GCM. Here is an overview of the basic steps:
- Implement an app server (the "3rd-party app server") to interact with your chosen GCM connection server. The app server sends data to a GCM-enabled Android client app via the GCM connection server. For more information about implementing the server side, see Implementing GCM Server.
- Write your client app. This is the GCM-enabled Android app that runs on a device. See Implementing GCM Client for more information.