C2DMAndroid Cloud to Device Messaging             Service        Joe Moore - @joem     Pivotal Labs - @pivotallabs
Pivotal Labs
Android’s pushmessaging service
Links• Code: http://github.com/joemoore/c2demo• App: https://market.android.com/details?  id=com.pivot13&feature=search_re...
SDK v8 and up
Surprisingly informal    support and    suggestions
“You should...”   “You may want to...”  Many of informal recommendations• Exponential back-off?• Google can do anything it...
There is no code• No Classes to help you handle C2DM  messages you receive• Google suggests using JumpNote or  Google Chro...
5 Step Process1. Sign up for the service2. “Server” authorizes to send C2DM   messages3. “Device” registers to receive C2D...
Sign Up
Server: Authorizing     Your Account• The sending server does this using account  email and password• Should use use a ded...
Device: Registering•   Must be signed in to a Google account•   Receiving device sends HTTP POST to Google:    Success or ...
onRegisterpublic class C2DMReceiver extends C2DMBaseReceiver {  @Override  public void onRegistered(Context context, Strin...
Server: Sending         Messages• Application server sends HTTP POST to  Google messages to a registration_id  (device)• R...
Device: Receiving       Messages• Receives an Intent• Extend JumpNote C2DM code and  implement your own handlers• Update N...
onRegisterpublic class C2DMReceiver extends C2DMBaseReceiver { @Override protected void onMessage(Context context, Intent ...
Clear All Button• notification.deleteIntent   =    PendingIntent.getBroadcast(...)•   Register a BroadcastReceiver to hand...
Upcoming SlideShare
Loading in...5
×

C2DM: Android Push

1,837

Published on

Slides from my C2DM talk at DroidconUK

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,837
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
50
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "C2DM: Android Push "

    1. 1. C2DMAndroid Cloud to Device Messaging Service Joe Moore - @joem Pivotal Labs - @pivotallabs
    2. 2. Pivotal Labs
    3. 3. Android’s pushmessaging service
    4. 4. Links• Code: http://github.com/joemoore/c2demo• App: https://market.android.com/details? id=com.pivot13&feature=search_result
    5. 5. SDK v8 and up
    6. 6. Surprisingly informal support and suggestions
    7. 7. “You should...” “You may want to...” Many of informal recommendations• Exponential back-off?• Google can do anything it wants?• Don’t send messages until Google says so... or else what?
    8. 8. There is no code• No Classes to help you handle C2DM messages you receive• Google suggests using JumpNote or Google Chrome to Phone Extension code
    9. 9. 5 Step Process1. Sign up for the service2. “Server” authorizes to send C2DM messages3. “Device” registers to receive C2DM messages4. “Server” Send C2DM messages5. “Device” Receives C2DM Messages
    10. 10. Sign Up
    11. 11. Server: Authorizing Your Account• The sending server does this using account email and password• Should use use a dedicated email address that can be changed (not a user’s email)• Might need to re-authorize at any time!
    12. 12. Device: Registering• Must be signed in to a Google account• Receiving device sends HTTP POST to Google: Success or Error• Device Receives Intent with registration_id• Must tell sender what it’s registraction_id is• registration_id can be revoked any time• Gotcha: can have multiple valid registration_ids per device
    13. 13. onRegisterpublic class C2DMReceiver extends C2DMBaseReceiver { @Override public void onRegistered(Context context, String regId) { super.onRegistered(context, registrationId); ... }}
    14. 14. Server: Sending Messages• Application server sends HTTP POST to Google messages to a registration_id (device)• Response will be success or an error• No guarantee it will be sent!• Might be told by Google to back off
    15. 15. Device: Receiving Messages• Receives an Intent• Extend JumpNote C2DM code and implement your own handlers• Update Notification Bar with the NotificationService
    16. 16. onRegisterpublic class C2DMReceiver extends C2DMBaseReceiver { @Override protected void onMessage(Context context, Intent intent) {}
    17. 17. Clear All Button• notification.deleteIntent = PendingIntent.getBroadcast(...)• Register a BroadcastReceiver to handle the Intent.
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×