This document provides an overview of Google Cloud Messaging (GCM) for Android, including:
1) GCM handles queuing and delivering messages from servers to Android apps to provide updated data or notifications even if apps aren't actively running.
2) It uses components like mobile devices, app servers, and GCM servers connected through credentials to ensure approved senders and delivery.
3) The registration process involves an app calling GCMRegistrar.register to get a registration ID to send to the app server for message sending.
4) App servers can send messages in JSON format to GCM servers, which then deliver messages to registered apps with features like multicasting, multiple senders, time
2. Introduction
Google Cloud Messaging for Android (GCM):
Its a service that helps developers send data from servers to their
Android applications on Android devices.
It could be a lightweight message telling application to fetch new data, or
a message with payload data to be consumed instantly.
GCM handles all aspects of queuing of messages and ensures delivery
to the application on target devices up to a great extent.
The best part, its totally free irrespective of your needs and has No Quota
system as we had with version of C2DM.
It’s a replacement to C2DM, which is now deprecated. As no more C2DM
signups are acceptable.
Provides backward support for devices running on Android 2.2 OS
version. Pre OS-Ver 3.x devices, it requires to setup at least on Google
account. Which is not at all required for devices running Ver-4.0 and
above.
1
3. GCM Architecture
Components: physical entities
– Mobile Device (running with 2.2 or above OS Version)
– 3rd Party App Server
– GCM Servers
Credentials: to ensure approved sender and delivery to correct
place
– SenderID (ProjectID)
– ApplicationID
– RegistrationID
– Google Account: if device running below ICS version.
– Sender Auth Token
2
7. Uniqueness of GCM: Features
Message Multicasting
– More than 1 devices can receive one message simultaneously
Multiple Senders with Single RegID
– More than 1 server can send messages to one App
TTL : Time To Live
– Expiry of sent messages
Messages with Payload
– To avoid sync with server for certain needs.
Throttle Queue
– GCM Optimization for battery
GCM Reliability
6
9. Multiple Senders
One common Registration ID
Multiple sender can send messages to one Application
Up to 100 Project IDs (Servers)
@Override
protected void onCreate(Bundle savedInstanceState) {
if (GCMRegistrar.getRegistrationId(this).equals(“”)) {
GCMRegistrar.register(this, “968350041068”, “652183961211”);
}
8
10. TTL: Time To Live
Indicates the duration to which GCM can store this message.
From 0 sec to 4 weeks
Messages with 0 will not be stored on GCM (Receive – Send –
Delete)
Default is 4 Weeks
Best Use case for Advertisements( Like sending deals and offers
during football match)
9
11. Messages with Payload
Payload up to 4K per message
Up to 100 Messages can be stored
Deletes all and creates a message to trigger sync after that
Best use for Ims and Online Server Gaming Apps
{
“message_type” : “deleted_messages”,
“total_deleted” : “115”,
},
10
12. GCM Optimization
Throttle Queue
– Provide fresh data all the time.
– Optimized for battery life.
– Delay in Delivery
Reliability
11