page.title=Getting Started page.tags="cloud","push","messaging" @jd:body

In this document

  1. Creating a Google API Project
  2. Enabling the GCM Service
  3. Obtaining an API Key
  4. Next Steps

See Also

  1. Google APIs Console page
  2. CCS and User Notifications Signup Form

This document tells you how to get started setting up a GCM implementation. Before you begin, make sure to set up the Google Play Services SDK. You need this SDK to use the {@code GoogleCloudMessaging} methods.

Creating a Google API project

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. From there you can create a new project by opening the project drop-down menu (upper left corner) and choosing Other projects > Create.

  3. Click Create project. Your browser URL will change to something like:
  4.  https://code.google.com/apis/console/#project:4815162342
  5. Take note of the value after #project: (4815162342 in this example). This is your project number, and it will be used later on as the GCM sender ID.

Enabling the GCM Service

To enable the GCM service:

  1. In the main Google APIs Console page, select Services.
  2. Turn the Google Cloud Messaging toggle to ON.
  3. In the Terms of Service page, accept the terms.

Obtaining an API Key

To obtain an API key:

  1. In the main Google APIs Console page, select API Access. You will see a screen that resembles the following:
  2. Click Create new Server key. Either a server key or a browser key should work. The advantage to using a server key is that it allows you to whitelist IP addresses. The following screen appears:
  3. Click Create:

Take note of the API key value (YourKeyWillBeShownHere) in this example, as it will be used later on.

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.

Next Steps

Once you've finished the tasks listed above, you're ready to start implementing GCM. Here is an overview of the basic steps:

  1. Decide which Google-provided GCM connection server you want to use— HTTP or XMPP (CCS). GCM connection servers take messages from a 3rd-party application server (written by you) and send them to a GCM-enabled Android application (the "client app," also written by you) running on a device.
  2. Implement an application server (the "3rd-party application server") to interact with your chosen GCM connection server. The app server sends data to a GCM-enabled Android client application via the GCM connection server. For more information about implementing the server side, see Implementing GCM Server.
  3. Write your client app. This is the GCM-enabled Android application that runs on a device. See Implementing GCM Client for more information.