Cloud to Device Messaging(with Google App Engine)<br />Lars Vogel<br />Twitter: @vogella<br />http://www.vogella.de<br />
About me – Lars Vogel <br />Works as independent Eclipse and Android Consultant and Trainer<br />Also works for SAP AG as ...
The challenge<br />Mobile Phone<br />Data in the Cloud<br />
Internet creates value for your application<br />
Getting the data<br />Polling  <br />Pushing<br />
Polling is easy<br />1.) Ask the server if new data is available2.) If new data is available download it3.) Sleep / wait 4...
Polling every 5 min can consume 10 % of your battery <br />
Pushing<br />Server informs the phone once new data is available<br />Info triggeres a download of data<br />
Cloud to Device Messaging<br />Available for Android 2.2 (Beta – Invite only)<br />Requires the Market available on the de...
C2DM – Building blocks<br />Gmail User for the application registration<br />Android Application<br />Googles C2DM server<...
C2DM Architecture<br />Googles C2DM Server<br />Android App<br />Your application server<br />
C2DM Architecture<br />Request registration ID<br />Unique registration ID<br />Googles C2DM Server<br />Android App<br />...
C2DM Architecture<br />Sends Registration ID to server<br />Android App<br />Server stores the registration ID <br />
Sending messages<br />New HTTP Post message with registration id and authentication token *<br />200 – ok (with id==ok)<br...
Return 200 with error<br />QuotaExceeded<br />InvalidRegistration<br />MessageTooBig<br />MissingCollapseKey<br />
C2DM Architecture<br />Sends notification message to device<br />Reads the real data from server<br />
Building the app<br />
Actually its relatively simple<br />Google provides some util classes<br />To register call: <br />C2DMessaging.register(c...
 Your C2DMReceiver<br />Gets the registration ID and send it to your server<br />
Permissions<br />
Register Googles Receiver<br />
Send registration ID to server<br />
Further points<br />Best effort delivery: Google will try to deliver all messages but some might get lost <br />Push can s...
Server can be anything<br />curl, php, <br />For testing build your server also on the phone....<br />
Your Java application server<br />
from Guillaume Laforge and Patrick Chanezon http://www.slideshare.net/glaforge/google-app-engine-java-groovy-baby<br />
Writing Java Webs application is annoyingly hard...<br />
Google App Engine<br />GAE allows you to host webapplications on the Google infrastructure.  <br />Scalable Infrastructure...
Google App Engine<br />No Server maintenance<br />Super easy deployment<br />
It automatically scales up and down<br />Computing power over time<br />
App Engine Architecture<br />Load Balancer<br />App Engine FrontEnd<br />App Engine FrontEnd<br />App Engine FrontEnd<br /...
GAE Key points<br />Deployment is super simple<br />Supports subset of JPA / JDO for persistence<br />Scalable per definit...
Receiving the registration ID<br />
Send out message<br />
Funny: Cloud vrs. Mobile<br />Cloud<br />No Threads (Webworkers)<br />No Access to file system<br />Only Key / Value (+JPA...
Summary <br />C2DM powerful and relatively simple to use<br />Google App Engine makes the server site easy<br />
Picture CreditsAdd the prefix http://www.sxc.hu/photo<br />Elephant: http://www.sxc.hu/photo/103473<br />Mouse http://www....
Futher information<br />C2DM Tutorial<br />http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html<br />...
Thank you<br />For further questions:<br />Lars.Vogel@gmail.com<br />http://www.vogella.de<br />http://www.twitter.com/vog...
License & Acknowledgements<br />This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative W...
Upcoming SlideShare
Loading in …5
×

Android Cloud to Device Messaging with the Google App Engine

12,459 views

Published on

Overview about Androids Cloud to Device Messaging (C2DM) and a short inside of the Google App Engine.

Published in: Technology
2 Comments
12 Likes
Statistics
Notes
No Downloads
Views
Total views
12,459
On SlideShare
0
From Embeds
0
Number of Embeds
78
Actions
Shares
0
Downloads
0
Comments
2
Likes
12
Embeds 0
No embeds

No notes for slide

Android Cloud to Device Messaging with the Google App Engine

  1. 1. Cloud to Device Messaging(with Google App Engine)<br />Lars Vogel<br />Twitter: @vogella<br />http://www.vogella.de<br />
  2. 2. About me – Lars Vogel <br />Works as independent Eclipse and Android Consultant and Trainer<br />Also works for SAP AG as Product Owner in a Scrum team<br />Maintains http://www.vogella.de Java, Eclipse and Android related Tutorials with ~20 000 visitors per day<br />
  3. 3. The challenge<br />Mobile Phone<br />Data in the Cloud<br />
  4. 4. Internet creates value for your application<br />
  5. 5. Getting the data<br />Polling <br />Pushing<br />
  6. 6. Polling is easy<br />1.) Ask the server if new data is available2.) If new data is available download it3.) Sleep / wait 4.) Repeat 1.)<br />
  7. 7.
  8. 8. Polling every 5 min can consume 10 % of your battery <br />
  9. 9. Pushing<br />Server informs the phone once new data is available<br />Info triggeres a download of data<br />
  10. 10. Cloud to Device Messaging<br />Available for Android 2.2 (Beta – Invite only)<br />Requires the Market available on the device<br />Use existing Google connections<br />Light-weight data will be send to the device<br />Message is specific to your application (via permission)<br />Use AlarmManager to keep the connection (Heartbeat)<br />
  11. 11. C2DM – Building blocks<br />Gmail User for the application registration<br />Android Application<br />Googles C2DM server<br />Your Application Server<br />
  12. 12. C2DM Architecture<br />Googles C2DM Server<br />Android App<br />Your application server<br />
  13. 13. C2DM Architecture<br />Request registration ID<br />Unique registration ID<br />Googles C2DM Server<br />Android App<br />Server might send new registration ID<br />
  14. 14. C2DM Architecture<br />Sends Registration ID to server<br />Android App<br />Server stores the registration ID <br />
  15. 15. Sending messages<br />New HTTP Post message with registration id and authentication token *<br />200 – ok (with id==ok)<br />404 – get no auth token<br />503 – Retry with backoff<br />
  16. 16. Return 200 with error<br />QuotaExceeded<br />InvalidRegistration<br />MessageTooBig<br />MissingCollapseKey<br />
  17. 17. C2DM Architecture<br />Sends notification message to device<br />Reads the real data from server<br />
  18. 18. Building the app<br />
  19. 19. Actually its relatively simple<br />Google provides some util classes<br />To register call: <br />C2DMessaging.register(context, Your.Email@gmail.com)<br />Register the Google provided C2DM broadcast receiver in your „AndroidManifest.xml“.<br />Google receiver will forward the information it receives to: <br /> context.getPackageName() + ".C2DMReceiver"<br />
  20. 20. Your C2DMReceiver<br />Gets the registration ID and send it to your server<br />
  21. 21. Permissions<br />
  22. 22. Register Googles Receiver<br />
  23. 23. Send registration ID to server<br />
  24. 24. Further points<br />Best effort delivery: Google will try to deliver all messages but some might get lost <br />Push can send 1024 characters -> not suited for big data, just notification <br />
  25. 25. Server can be anything<br />curl, php, <br />For testing build your server also on the phone....<br />
  26. 26. Your Java application server<br />
  27. 27. from Guillaume Laforge and Patrick Chanezon http://www.slideshare.net/glaforge/google-app-engine-java-groovy-baby<br />
  28. 28. Writing Java Webs application is annoyingly hard...<br />
  29. 29. Google App Engine<br />GAE allows you to host webapplications on the Google infrastructure. <br />Scalable Infrastructure<br />
  30. 30. Google App Engine<br />No Server maintenance<br />Super easy deployment<br />
  31. 31. It automatically scales up and down<br />Computing power over time<br />
  32. 32. App Engine Architecture<br />Load Balancer<br />App Engine FrontEnd<br />App Engine FrontEnd<br />App Engine FrontEnd<br />AppServer<br />AppServer<br />AppServer<br />
  33. 33. GAE Key points<br />Deployment is super simple<br />Supports subset of JPA / JDO for persistence<br />Scalable per definition<br />Free to get started (significant volume)<br />
  34. 34. Receiving the registration ID<br />
  35. 35. Send out message<br />
  36. 36. Funny: Cloud vrs. Mobile<br />Cloud<br />No Threads (Webworkers)<br />No Access to file system<br />Only Key / Value (+JPA, JDO)<br />Time limited for requests 30 <br />Mobile<br />Threads<br />Access to file system<br />SQL Datebase<br />Time limited for Activity 5 secs<br />
  37. 37. Summary <br />C2DM powerful and relatively simple to use<br />Google App Engine makes the server site easy<br />
  38. 38. Picture CreditsAdd the prefix http://www.sxc.hu/photo<br />Elephant: http://www.sxc.hu/photo/103473<br />Mouse http://www.sxc.hu/photo/1097314<br />Liquid http://www.sxc.hu/photo/1109534<br />Beta 853828<br />Despair 150108<br />Old Computer http://www.sxc.hu/photo/1028528<br />Person with remote http://www.sxc.hu/photo/485640<br />Victory fingers 906072<br />Guy with a tie 877661<br />
  39. 39. Futher information<br />C2DM Tutorial<br />http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html<br />Google App Engine Tutorial<br />http://www.vogella.de/articles/GoogleAppEngineJava/article.html<br />Chrome to Phone Example <br />http://code.google.com/p/chrometophone/<br />
  40. 40. Thank you<br />For further questions:<br />Lars.Vogel@gmail.com<br />http://www.vogella.de<br />http://www.twitter.com/vogella<br />
  41. 41. License & Acknowledgements<br />This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License<br />See http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en_US<br />

×