Monday, November 28, 2011

How To Google's Cloud to Device Messaging

This Cloud to Device Messaging is a solution to send real-time notifications to user on their Android handset. This is supported by most of the Google Services such as Gmail, Market, and Maps. This messaging server/service takes care of all aspects of queuing and delivery of messages to target devices running developer's target apps. This service also acts as an intermediary between developer's App server and Android device.

This article highlights the prerequisites for Google's cloud service implementations:

• The OS version for Android Device or emulator should be 2.2+.
• At least one user needs to be logged in Google user on device/emulator.
• There should be one application server which can talk to HTTP and connect to messaging server.
• Android application should have permissions to receive message and allowed to connect to the internet connection.
• Developer must register on this service's official site to use this technology for his application and to get developer quota for the cloud to device receiving messages.

The key advantages of cloud to device based service implementation are:

• Application need not be running in background to receive push messages, as those are delivered to the app (Intent Receiver) by using Intent broadcast system.
• It does not create additional burden on network as it uses existing connection to Google services.
• The device to Google's cloud server connection is based on SSL (Secure Sockets Layer) protocol; hence data delivery to device is secured.
• Broken connections are re-established using heartbeat implementation.
• Google's framework for this service does not provide any built-in user interface to display the received push message content. This framework allows the application to completely control the received raw message content.
• For example, the application might post a notification, display a custom user interface, or silently synchronize data.

Some of the limitations to Google's cloud implementation include:

• The push message size limit is 1K (1024 bytes).
• The short data messages framework doesn't give guarantee about delivery or order of push messages.
• This Google cloud system's sender account will have daily limit on total number of messages sent as well as messages sent per device. Currently total limit is 200,000 messages per day.

Some guidelines for the developers are highlighted below:

• When Google service is down the application will get HTTP error code 503 along with retry value. The application should respect these kinds of errors and it should have advanced error-handling mechanism in place.
• The solution should have its own queue mechanism in place, which will be useful when the most awaited feature of Android 2.2 service returns over quota error.
• Application server should not send large data; instead, it should send 'tickles' to the application telling it to download latest data from server.
• Avoid using 'Role Account Email ID' on device.

This cloud to device service provides better user experience for end-user without any additional cost. This service is free; while other alternates such as SMS or polling mechanism can cost more for user, in terms of network usage and battery consumption. Since most of the Google applications available on android Smartphones are using this infrastructure we can be sure that this service is stable & reliable.

No comments:

Post a Comment