Presentation is loading. Please wait.

Presentation is loading. Please wait.

FCM Workflow using GCM.

Similar presentations


Presentation on theme: "FCM Workflow using GCM."— Presentation transcript:

1 FCM Workflow using GCM

2 Agenda Polling Mechanism What is GCM Need / advantages of GCM
GCM Architecture Working of GCM GCM – Send to Sync [ HTTP ] and Send Data [ XMPP ] Google Cloud Messaging – APIs Implementation

3 Existing FCM uses Polling
Any new updates ? No Any new updates ? No Any new updates ? YES Polling is simple to implement, But Polling consumes lot of battery , resource. Extra Network Usages. Polling is about checking periodically for updates on your server and is bad for several reasons: 1) it consumes lot of battery, periodically waking up the mobile device network stack. 2) it consumes a lot of useless resources on the server as most of this resource lead to a “no update” reply. 3) it introduces latency as the request for new data can happen long after the data availability (unless you put a very low polling interval, which is even worse for the mobile battery). You can get your news alert hours after every one already knows about it, which defeat the purpose of the alert in the first place.

4 GCM Google Cloud Messaging have been announced last year as a replacement of Google Cloud to Device Messaging. This is a service that allows mobile developer to notify mobile devices (but also Chrome browser) about important changes on the server-side component of the application. It makes it possible for the device to stay up to date, without the need to use polling.

5 What is GCM GCM stands for Google Cloud Messaging.
It is a free service that allows you to send data from your servers to your users and vice versa. Handles queuing of messages and delivery to the target application.

6 Need / advantages of GCM
Application does not need to be running in the background for receiving data messages. The system will wake up the Android application via Intent broadcast when the message arrives. Lower cost and better tracking than SMS Scalability & extensibility GCM is completely free no matter how big your messaging requirements

7 GCM Architecture Google-provided GCM Connection Servers take messages from a 3rd-party application server and send these messages to a GCM-enabled Android application (the "client app") running on a device. Currently Google provides connection servers for HTTP and XMPP. The 3rd-Party Application Server is a component that you implement to work with your chosen GCM connection server(s). App servers send messages to a GCM connection server; the connection server enqueues and stores the message, and then sends it to the device when the device is online. The Client App is a GCM-enabled Android application running on a device. To receive GCM messages, this app must register with GCM and get a registration ID. If you are using the XMPP(CCS) connection server, the client app can send "upstream" messages back to the connection server.

8 Working of GCM 1.Request for Registration GCM
2.Reply with Registration Id 5. Send Message Mobile App 3.Send Registration Id 4. Send message {RegId, msg }

9 GCM – Send to Sync [HTTP]
2. Send Notification message Mobile App 3. Download data 1. Send Notification message Give example of application. Give example of sending notification to the users to download videos or pictures.

10 GCM – Send Data [ XMPP ] GCM Send message Mobile App Send message
Persistent XMPP connection Mobile App Send message Give example of Instant Messaging Application. Give example of my favourite location on surf application.

11 Time To Live and Delay While Idle
Google Cloud Messaging – APIs Time To Live and Delay While Idle Multiple Senders Message Multicasting A) Time to live: allows you to set expiration date for a message. For example the surf application identify that my favourite location due to wind and tidy weather is a place which is perfect for surfing from this hour to next hour. So if GCM discovers that time is expired before device comes online, it simply drop that message. By Default time is 4 weeks. B) Delay when idle: can be use for less urgent notifications. Device will get it when becoming active again. Multiple Sender: GCM is even powerful when multiple senders want to send data to the same application. Multicasting: To send message via GCM, you need to use open http connection. When you want to connect to all of your users, it is difficult to open these many http connections. For 1000 recipeints 1 http request per message(GCM provides this facility).

12 Implementation Creating a Google API project Enabling the GCM Service
GCM Server Creating a Google API project Enabling the GCM Service

13 Implementation Copy the required libs Make changes to the manifest
Mobile App Copy the required libs Make changes to the manifest Add a broadcast receiver Add an Intent service Wire it up in your activity

14 Implementation Application Server Expose Service to receive and store user information and GCM registration Id. Send message to GCM service.

15 Minimum requirements ( device side )
Android 2.2 + Google Play Store application should be installed Internet connection Google account ( device version < ) For Developer Emulator with Google APIs

16 References https://developer.android.com/google/gcm/index.html
Presentation by Francesco Nerieri

17 Thank you Any questions?


Download ppt "FCM Workflow using GCM."

Similar presentations


Ads by Google