Android Cloud2Device Messaging
Upcoming SlideShare
Loading in...5
×
 

Android Cloud2Device Messaging

on

  • 1,524 views

 

Statistics

Views

Total Views
1,524
Views on SlideShare
1,510
Embed Views
14

Actions

Likes
2
Downloads
38
Comments
0

2 Embeds 14

http://www.linkedin.com 12
https://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Android Cloud2Device Messaging Android Cloud2Device Messaging Presentation Transcript

  • AndroidCloud2DeviceMessagingCommunicate with yourapp!Mando StamelakiM-STAT – Mobile Application Developer | | |2012 Copyright M-STAT SA
  • Android Cloud to Device Messaging Framework (AC2DM) What is Android C2DM Framework?Introduction to AC2DM Android Cloud to Device Messaging (C2DM) is – a service that helps developers send data from servers to their applications on Android devices.Google Service for The service provides a:pushing messages to – simple,Android devices. – lightweight mechanism that servers can use to: – tell mobile applications to contact the server directly, – fetch updated application or user data. Push Notifications for The C2DM service handles Android Phones, – all aspects of queuing of messages and Tablets and other – delivery to the target application running on the target devices. device.Mando Stamelaki | Android Cloud2Device Messaging
  • AC2DM Android Cloud to device Messaging, provided free by Google Servers Advantages Disadvantages• 3rd party application servers send lightweight • C2DM makes no guarantees about delivery messages to their Android applications. or the order of messages.• An application on an Android device doesn’t • Does not provide built-in user interface or need to be running to receive messages. other handling for message data.• Uses an existing connection for Google • Requires devices running Android 2.2 or services, with the set up Google account on higher that also have the Market application mobile device. installed.Mando Stamelaki | Android Cloud2Device Messaging
  • coming M-STAT Service In the role of 3rd party server soon Server-side Mobile Application Encountering C2DM disadvantages• No need to setup a server in • Easy integration in your • Application ability to inform order to send notification Application M-STAT server when a push messages. message is received • Full documentation for• User friendly environment. developers • Library provides a built-in handler for messages• Cross-platform push • Documented code examples notifications (iOS supported, Windows Phone on the way!) • Easy customizable to your app needs.Mando Stamelaki | Android Cloud2Device Messaging
  • C2DM communication Communication flow between M-STAT (3rd party server) and Google request register Android registration id Application Servers (Device) (C2DM | Client Login) Push message registration id send id | error [tags] registration id message key id authorization Notification requests Server authorization authorizationMando Stamelaki | Android Cloud2Device Messaging
  • M-STAT Server HTTP Communication protocol REGISTER • A device for push notifications • Update an existing device CURRENT STATUS • Registration status and tags if any UNREGISTER • Remove a device from the listMando Stamelaki | Android Cloud2Device Messaging
  • Preferences Preferences • Enable / Disable C2DM service • Register/Unregister from Google • Register/Unregister from M-STAT • Register to specific notification tags • An app can let users receive notifications for specific things (up to each developer) and not everything • Retrieve registration statusMando Stamelaki | Android Cloud2Device Messaging
  • Software Development Kit for M-STAT Notification Service The SDK contains: • Library • Mobile App • ExamplesMando Stamelaki | Android Cloud2Device Messaging
  • SDK Library • Implementing the process to register and unregister from Google servers. • Connect to M-STAT’s servers and pass the registration id, and other preferences.Mando Stamelaki | Android Cloud2Device Messaging
  • SDK Mobile Helping App • Representing the usage of library • Helping developers to test the service without having to implement their own application.Mando Stamelaki | Android Cloud2Device Messaging
  • Let’s CODE!!!
  • Start with . . . adding the Library to your projectMando Stamelaki | Android Cloud2Device Messaging
  • Integrate M-STAT’s library AndroidManifest.xml (1 of 2) <xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="gr.mstat.example" android:versionCode="1" android:versionName="1.0" > <!-- Android 2.2 --> <uses-sdk android:minSdkVersion="8" /> <!-- Permissions --> <permission android:name="gr.mstat.example.permission.C2D_MESSAGE“ android:protectionLevel="signature" /> <uses-permission android:name="gr.mstat.example.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- ... other permissions here ... -->Mando Stamelaki | Android Cloud2Device Messaging
  • Integrate M-STAT’s library AndroidManifest.xml (2 of 2)<application><!-- ... any activities | services | receivers here ... --> <service android:name="gr.mstat.c2dm.C2DMReceiver" /> <receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <!-- Receive the actual message --> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <category android:name="gr.mstat.example" /> </intent-filter> <intent-filter> <!-- Receive the registration id --> <actionandroid:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="gr.mstat.example" /> </intent-filter> </receiver></application><!-- ... other code here ... --></manifest>Mando Stamelaki | Android Cloud2Device Messaging
  • Calling the library Startup class or any class where you want the notification service being initialized Still under “deep thought” but will look to something like…Single line initialization // this refers to a Context object // OPTION 1:Different ways of // Starts up the service according to a preferenceinitialization from application preferences PushNotification.registerAuto(this);Customized preferences // OPTION 2: // Manual register or unregister to the service PushNotification.register(this, true);BUT ALL WITH: PushNotification.register(this, false);As less coding as // OPTION 3:possible!!! // Registration to specific tag notifications ArrayList<String> tags = new ArrayList<String>();Library does the dirty tags.add("tag_name_1");job! // ... any other tags developer wants tags.add("tag_name_v"); PushNotification.register(this, tags); // choose according to your needs!Mando Stamelaki | Android Cloud2Device Messaging
  • Any Questions?
  • Resources Resources 1. Google Projects for Android: C2DM http://code.google.com/android/c2dm/ 2. Android Cloud To Device Messaging http://android-developers.blogspot.com/2010/05/android-cloud-to-device- messaging.html 3. Android C2DM Push Notification http://stackoverflow.com/questions/6276342/android-c2dm-push-notification 4. Android C2DM server and client implementation working http://markmelive.com/2011/04/android-c2dm-server-and-client- implementation-working/ 5. C2DM Tutorial Send push notifications to your applications with Android C2DM | Cloud To Device Messaging Tutorial http://www.hightechno.info/2011/08/c2dm-tutorial-send-push-notifications.html 6. Android Cloud to Device Messaging (C2DM) - Tutorial http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html 7. Cloud to device messaging http://www.androidkit.com/cloud-to-device-messagingMando Stamelaki | Android Cloud2Device Messaging
  • Mando Stamelaki  THANK YOUMobile Application Developerm.stamelaki@m-stat.gr M-STAT | Android Clould2Device Messaging