Mobile Opinion Tech Talk

Tech Talk: Cross-Platform Messaging using Google Cloud Messaging

Back in 2010, Google introduced C2DM (Cloud to Device Messaging) as a way to push messages from cloud to Android powered devices. This service was eventually replaced by GCM (Google Cloud Messaging). C2DM is now deprecated & the service will be shut down completely on 20 Oct 2015.

Screen shot 2015-09-25 at 4.11.38 PM

The GCM focuses on addressing some of the problems in C2DM as mentioned below:

  • Developers had to sign-up for C2DM using a form & the access would be provided through e-mail after a few days. GCM just requires that you enable it from Google Developer Console & the access is immediately granted.
  • GCM doesn’t have a quota based system.
  • GCM is built keeping in mind device’s battery efficiency.
  • GCM provides rich set of APIs. API libraries are available for each platform.

GCM has progressively added features over the years. The latest version as of this writing supports the following features.

Cross-platform

Supports Android, iOS & Chrome platforms. The advantage here is that app server needs to communicate with one server viz, GCM rather than multiple servers e.g., APNS. iOS apps can communicate via APNs bridge or independently. Chrome apps & extensions can leverage messaging services.

Group messaging

Groups of up to 20 devices can be created. It is easy to add/remove devices from the group. This is useful to message/sync connected devices belonging to the same user.

Topic messaging

Allows to send messages only to devices that have opted-in to a particular topic. This uses a PubSub model. Receivers subscribe to a topic. Producers publish to a topic. For example, users of a sports app could opt-in to receive messages regarding 20-20 format Cricket matches only.

Upstream messaging

In addition to using HTTP for downstream messaging, XMPP can be used for duplex (downstream & upstream) communication. On the server, the asynchronous nature of XMPP allows you to send more messages with fewer resources. On the device, since the connection is reused for sending/receiving,this improves battery life.

Lifespan

There are several aspects that can be used to control the lifespan of the message. Message priority can be changed. The TTL option decides how long the message is saved on the GCM server before it is discarded (message is stored until it is delivered to the device). The GCM server will wait until the device wakes up, before delivering the message, if delay-while-idle option is set.

Collapsible

A collapsible message is a message that may be replaced by a new message containing the same collapse key if it has yet to be delivered to the device. Ping messages which request the device to sync/refresh its data or breaking news message in a news app are such candidates.

Batch requests

GCM supports sending multicast messages for up to 1000 devices using a single request. This can conserve app server resources.

Multiple app servers

Multiple app servers can send messages to the same app on a device by sharing the registration id. For example, content aggregation apps can receive messages from multiple content sources.

 

Google’s cloud messaging has come a long way from simplistic downstream messaging to the sophisticated messaging system it is today. It would be nice if the limits applicable on the number of topic subscriptions & group size are removed.

Sudheer K Bhat
Sudheer K Bhat is a Solutions Architect at Robosoft whose specialities include mobility solutions, Digital TV, MEAP, Retailing and Supply Chain Management.

Leave Your Comment

Your Comment*

Your Name*
Your Webpage