Use Google Cloud Messaging (GCM)

Google Cloud Messaging (GCM) is a free service that helps developers send messages across multiple platforms: Android, iOS, and Chrome. For example, a server can send messages directly to single devices, groups of devices, or devices subscribed to topics. Also, the application on a device can send messages directly to a server and to devices belonging to the same group.

GCM replaces beta version of C2DM (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

Add Google Cloud Messaging

To add GCM to your app, visit the Google Developers site. GCM is included in "Cloud Messaging."

Add GCM to your app

GCM statistics

You can 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 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.

GCM message status

  • Accepted: Arrived at GCM
  • Stored: Stored in GCM, pending redelivery, until the message is either expired or collapsed
  • Delivered: Sent to device
  • Acknowledged: Device has confirmed it received the message
  • Collapsed: Have a collapse key that has been replaced by other messages with the same collapse key
  • Expired: Reached their time-to-live (TTL) and expired
  • Invalid Request: Reached GCM and are invalid. GCM rejected them for any further processing. You can find details on these failures on the Server API Reference
  • Sent after reconnect, with delay: Sent to the device after some delay upon reconnecting to the GCM servers
  • Sent on reconnect: Sent to device when device has reconnected to GCM
  • Accepted, sent to APNS: Arrived at GCM and sent to APNS for delivery to the iOS device
  • Failed by APNS: Arrived at GCM, but failed when forwarded to APNS for delivery to the iOS device

GCM diagnostics

Using GCM Diagnostics, you can troubleshoot messages sent through GCM. You can look up the message(s) by Registration token or Message ID.

Here's how to get to your GCM Diagnostics page:

  1. Sign in to your Google Play Developer Console.
  2. Select an app that uses GCM.
  3. On the left menu, click GCM Diagnostics.

Here's how you can look up messages sent through Google Cloud Messaging:

  • Registration token: The GCM identity of the client app on the device. You can find it when your client app registers with GCM. This is also the identity that you'll use to send a GCM message to a device.
    • You should only look up one Registration token at a time.
  • Message ID: The unique GCM message identifier. You can find it in the response message that GCM sends to the client server when GCM confirms that it has received the message.
    • You can look up multiple Message IDs at a time, but they should all be related to the same Registration token.
    • To learn about the different message statuses, refer to the GCM message status section.

Collapsed messages overview

If a message is sent with the option collapse_key, and it hasn't been delivered to the device when another message with the same collapse_key arrives, the original message will have a "Collapsed" status.

The Collapsed messages overview shows sequence of messages with the same collapse key until the last message of the sequence has reached a non Collapsed status (Example: Delivered, Acknowledged, Stored, Expired)

You can find the collapse_key API references and examples on the Developers site.

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.

Was this article helpful?
Yes
No