As of April 10, 2018, Google has deprecated GCM. The GCM server and client APIs are deprecated and will be removed as soon as May 29, 2019. Migrate GCM apps to Firebase Cloud Messaging (FCM), which inherits the reliable and scalable GCM infrastructure, plus many new features. See the migration guide to learn more.

About GCM Connection Server

The server side of Google Cloud Messaging (GCM) consists of two components:

  • GCM connection servers provided by Google. These servers take messages from an app server and send them to a client app running on a device. Google provides connection servers for HTTP and XMPP.
  • An application server that you must implement in your environment. This application server sends data to a client app via the chosen GCM connection server, using the appropriate XMPP or HTTP protocol.

A full GCM implementation requires both a client implementation and a server implementation. For more information about implementing the client side, see the GCM client guide for your platform: Android, iOS, or Chrome.

Role of the Application Server

Before you can write client apps that use GCM, you must have an application server that meets the following criteria:

  • Able to communicate with your client.
  • Able to send properly formatted requests to the GCM connection server.
  • Able to handle requests and resend them using exponential back-off.
  • Able to securely store the server key and client registration tokens. Note: never include the server key in any client code.
  • For XMPP, the server must be able to generate message IDs to uniquely identify each message it sends (GCM HTTP connection server generates message IDs and returns them in the response). XMPP message IDs should be unique per sender ID.

You'll need to decide which GCM connection server protocol(s) you want to use to enable your app server to interact with GCM connection servers. Note that if you want to use upstream messaging from your client applications, you must use XMPP. For a more detailed discussion of this, see Choosing a GCM Connection Server.

Choosing a GCM Connection Server Protocol

Currently GCM provides two connection server protocols: HTTP and XMPP. Your app server can use them separately or in tandem. XMPP messaging differs from HTTP messaging in the following ways:

  • Upstream/Downstream messages
    • HTTP: Downstream only, cloud-to-device up to 4KB of data.
    • XMPP: Upstream and downstream (device-to-cloud, cloud-to-device), up to 4 KB of data.
  • Messaging (synchronous or asynchronous)
    • HTTP: Synchronous. App servers send messages as HTTP POST requests and wait for a response. This mechanism is synchronous and blocks the sender from sending another message until the response is received.
    • XMPP: Asynchronous. App servers send/receive messages to/from all their devices at full line speed over persistent XMPP connections. The XMPP connection server sends acknowledgment or failure notifications (in the form of special ACK and NACK JSON-encoded XMPP messages) asynchronously.
  • JSON
    • HTTP: JSON messages sent as HTTP POST.
    • XMPP: JSON messages encapsulated in XMPP messages.
  • Plain Text
    • HTTP: Plain Text messages sent as HTTP POST.
    • XMPP: Not supported.
  • Multicast downstream send to multiple registration tokens.
    • HTTP: Supported in JSON message format.
    • XMPP: Not supported.

Send feedback about...

Cloud Messaging
Cloud Messaging