the challenge
play

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


  1. G OOGLE CLOUD MESSAGING FOR ANDROID Bindu Priya Infosys Limited Image Courtesy: http://developer.android.com/guide/google/gcm

  2. The Challenge Mobile Phone Data in the cloud

  3. H OW TO KEEP DATA ON YOUR DEVICE F RESH ? Polling Pushing

  4. Polling is Simple to Implement Any New Updates? No Any New Updates? No Device Application server

  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 of the Phone

  6. Pushing Server Informs the phone once the new data is available Data Device Application server

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

  8. Android Cloud to Device Messaging C2DM Live Score Score Server Live Score App

  9. Android Cloud to Device Messaging • Google Account • Client Login Token • Sign up Form • Activation Email Activation Email • Initial Quota

  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.

  11. Google Cloud Messaging-Building Blocks • Google account for application registration • Android Application • GCM Server GCM Server • Your Application Server

  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 Application Server Phone

  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.

  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.

  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 .

  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”); }

  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); } }

  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);

  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" />

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

  21. Message Multicasting • One Message multiple devices • Allows up to 1000 devices simultaneously.

  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.

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

  24. Q UESTIONS ?

  25. T HANK YOU

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend