page.title=Getting Started
page.tags="cloud","push","messaging"
@jd:body
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:
- Open the Google APIs Console page.
- If you haven't created an API project yet, this page will prompt you to do so:
![]({@docRoot}images/gcm/gcm-create-api-proj.png)
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.
- Click Create project.
Your browser URL will change to something like:
https://code.google.com/apis/console/#project:4815162342
- 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:
- In the main Google APIs Console page, select Services.
- Turn the Google Cloud Messaging toggle to ON.
- In the Terms of Service page, accept the terms.
Obtaining an API Key
To obtain an API key:
- In the main Google APIs Console page, select API Access.
You will see a screen that resembles the following:
- 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:
- 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:
- 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.
- 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.
- Write your client app. This is the GCM-enabled Android application that runs
on a device. See Implementing GCM Client for more information.