Use Google Cloud Messaging (GCM)

Google Cloud Messaging (GCM) is a free service that helps developers send data from servers to their Android applications. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4KB of payload data (so apps like instant messaging can consume the message directly).

GCM replaces beta version of C2DM (Android Cloud to Device Messaging). Please note that C2DM is now deprecated, and that we are no longer allowing new C2DM sign-ups. Learn how to migrate from C2DM to GCM

Create a Google API project

To use GCM, you need to obtain a long-lived token (simple API key). If you're an existing C2DM user, you can use your C2DM token instead.

To create a Google API project, follow these steps:

  1. Open the Google Developers Console.
  2. If you haven't created an API project yet, near the top of the screen, click Create Project.
  3. Type a project name.
  4. Click Create.
  5. Once the project has been created, a page appears that displays your project ID and project number.
    • Example: Project Number 670330094152
  6. Take note of your project number. You’ll use it later as your GCM sender ID.
Need help getting an API key? Visit the Android Developers site for step-by-step instructions.

GCM statistics

Developers will be able to sign-up for GCM for both Play and non-Play apps. However, GCM stats will be available for only published Google Play apps. To be able to see GCM stats in your Google Play Developer Console, associate the GCM Simple API Key or C2DM token with your Android application. Here’s how:

  1. Sign in to your Google Play Developer Console.
  2. Select an app.
  3. On the left menu, click Services & APIs.
  4. Click the Link a sender ID button.
  5. Type your GCM API key or C2DM client login token.
  6. Click Link.

Note that you can also revoke your key or a token through Google APIs console. After the key or token is revoked, you can continue to see GCM stats on your app's Statistics page in your Google Play Developer Console until you remove the GCM sender ID.

Types of statistics

  • Invalid request: Messages failed during a request where we returned an error_code or non-200 http stats code to the third party.
  • Sent: Messages successfully sent to device.
  • Expired: Messages that reached their time-to-live (TTL) and expired.
  • Collapsed: Messages that have a collapse key and have been collapsed by other incoming messages with the same collapse key.
  • Stored: Messages that don’t belong to other statuses and are stored in our servers.

Changes to GCM data

February 17, 2015: Delivered messages & expired state

Delivered messages

The number of GCM messages described as "Delivered" was being underreported. Some "Delivered" messages were described as "Stored." These issues have been corrected for new data, but it wasn’t possible to retrospectively correct older statistics.

Note: The total number of messages was correct.

New expired state

A new message state of "Expired" has been added to GCM. The "Expired" state refers to messages that couldn’t be delivered before their time to live (ttl) expired and were discarded. Previously, these messages were included in the "Stored" message count.

How helpful is this article:

Feedback recorded. Thanks!
  • Not at all helpful
  • Not very helpful
  • Somewhat helpful
  • Very helpful
  • Extremely helpful