This document provides an introduction to Android Cloud to Device Messaging (AC2DM), which allows servers to send data to Android applications. It describes how AC2DM handles message queueing and delivery. The advantages of AC2DM include lightweight messaging to apps without needing to be running. Disadvantages include no guarantees on delivery order. It also describes an M-STAT service that addresses some AC2DM disadvantages and provides a library and SDK to integrate push notifications.
2. 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
3. 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
4. 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
5. 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
authorization
Mando Stamelaki | Android Cloud2Device Messaging
6. 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 list
Mando Stamelaki | Android Cloud2Device Messaging
7. 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 status
Mando Stamelaki | Android Cloud2Device Messaging
8. Software Development Kit for M-STAT Notification Service
The SDK contains:
• Library
• Mobile App
• Examples
Mando Stamelaki | Android Cloud2Device Messaging
9. 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
10. 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
14. 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 -->
<action
android: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
15. 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 preference
initialization 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