The Challenge Mobile Phone Data in the cloud H OW TO KEEP DATA ON - - PowerPoint PPT Presentation

the challenge
SMART_READER_LITE
LIVE PREVIEW

The Challenge Mobile Phone Data in the cloud H OW TO KEEP DATA ON - - PowerPoint PPT Presentation

G OOGLE CLOUD MESSAGING FOR ANDROID Bindu Priya Infosys Limited Image Courtesy: http://developer.android.com/guide/google/gcm The Challenge Mobile Phone Data in the cloud H OW TO KEEP DATA ON YOUR DEVICE F RESH ? Polling Pushing Polling is


slide-1
SLIDE 1

GOOGLE CLOUD MESSAGING

FOR ANDROID

Bindu Priya Infosys Limited

Image Courtesy: http://developer.android.com/guide/google/gcm

slide-2
SLIDE 2

The Challenge

Data in the cloud Mobile Phone

slide-3
SLIDE 3

HOW TO KEEP DATA ON YOUR

DEVICE FRESH?

Polling Pushing

slide-4
SLIDE 4

Polling is Simple to Implement

Any New Updates? No Any New Updates? No Device Application server

slide-5
SLIDE 5

Polling Every 5 min can consume 10% of your battery AND.. Nobody appreciates the apps Nobody appreciates the apps which drains the battery life

  • f the Phone
slide-6
SLIDE 6

Pushing

Server Informs the phone once the new data is available

Data

Device Application server

slide-7
SLIDE 7

C2DM Framework

How many of you have heard about Cloud to Device Messaging Framework

slide-8
SLIDE 8

Android Cloud to Device Messaging

Live Score C2DM Score Server Live Score App

slide-9
SLIDE 9

Android Cloud to Device Messaging

  • Google Account
  • Client Login Token
  • Sign up Form

Activation Email

  • Activation Email
  • Initial Quota
slide-10
SLIDE 10

Google Cloud Messaging

  • Simple to use
  • No Client Login Token
  • No Signup Form
  • No Quotas
  • No Quotas
  • Takes 4.7ms to deliver

the messages.

slide-11
SLIDE 11

Google Cloud Messaging-Building Blocks

  • Google account for application registration
  • Android Application

GCM Server

  • GCM Server
  • Your Application Server
slide-12
SLIDE 12

How GCM Works

GCM Server

1.Registers Application with GCM and gets the API Key and Project ID

  • 4. Sends Registration ID to the server

Phone Application Server

slide-13
SLIDE 13
  • 1. Create Google API Project
  • Go to https://code.google.com/apis/console
  • Click on create project and this will generate a

Project ID which will be used as GCM Sender ID.

slide-14
SLIDE 14
  • 2. Enable GCM Service
  • In the main Google APIs Console page,

select Services.

  • Turn the Google Cloud Messaging to ON.

In the Terms of Service page, accept the

  • In the Terms of Service page, accept the

terms.

slide-15
SLIDE 15
  • 3. Obtain API Key
  • In the main Google APIs Console page, select API Access.
  • Click Create new Server key. Either a server key or a

browser key should work .

slide-16
SLIDE 16
  • 4. Get Registration ID for the device

import com.google.android.gcm.GCMRegistrar; @Override protected void onCreate(Bundle savedInstanceState) { if (GCMRegistrar.getRegistrationId(this).equals(“”)) { if (GCMRegistrar.getRegistrationId(this).equals(“”)) { GCMRegistrar.register(this, “12345678910”); }

slide-17
SLIDE 17
  • 5. Send Registration Id to server

import com.google.android.gcm.GCMBaseIntentService; public class GCMIntentService extends GCMBaseIntentService { @Override protected void onRegistered(Context ctx, String regId) { protected void onRegistered(Context ctx, String regId) { sendToLiveScoreServer(regId); } }

slide-18
SLIDE 18
  • 6. Server sends messages to GCM

import com.google.android.gcm.server.*; Sender sender = new Sender(myApiKey); Message message = new Message.Builder().build(); MulticastResult result = sender.send(message, devices, MulticastResult result = sender.send(message, devices, 5);

slide-19
SLIDE 19

7.Declare Permissions

<!-- App receives GCM messages. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- GCM connects to Google Services. --> <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.GET_ACCOUNTS" />

slide-20
SLIDE 20

Live Score Server GCM Auth REG ID, API Key REG ID, API Key API Key Project ID Live Score App

slide-21
SLIDE 21

Message Multicasting

  • One Message multiple devices
  • Allows up to 1000 devices simultaneously.
slide-22
SLIDE 22

GCM Time To Live

  • From 0 to 4 weeks
  • Messages with TTL as 0 are not stored on

GCM Default value is 4 weeks.

  • Default value is 4 weeks.
slide-23
SLIDE 23

Summary

  • Many Android apps access data in cloud
  • Push keeps apps up to date, efficiently
  • Android Google Cloud Messaging makes push

simple simple

slide-24
SLIDE 24

QUESTIONS?

slide-25
SLIDE 25

THANK YOU