27-10-2016, 02:31 PM
1461738063-gcmdocument.docx (Size: 764.24 KB / Downloads: 5)
ABSTRACT
.
Google Cloud Messaging for Android (GCM) is a service that helps developers to send data from servers to their Android applications on Android devices. The service was unveiled on June 27, 2012, at Google I/O 2012 held at the MosconeCenter in San Francisco.The GCM service handles all aspects of queuing of messages and delivery to the target Android application running on the target device. It is completely free whatever your messaging needs are and it can be used in some applications like smart notification systems.
GCMin real world experiments,and at a reasonable scale involving thousands of real users. Our findings reveal that the GCM message delivery is unpredictable, namely having a reliable connection to Google’s GCM servers on the client device does not guarantee a timely message arrival. Therefore, GCM is not suitable for time sensitive and/or “must-deliver-to-all” app scenarios. On the other hand, GCM delivers the push messages to a big portion of the subscribers (more than 40% in any experiment scenario) in a reasonable timeframe (in 10 seconds).Therefore, GCM may be a good fit for the application scenarios where random multicasting is sufficient, such as crowdsourcingsystems.
INTRODUCTION
Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to the users' Android-powered device. This could be a lightweight message telling your app there is new data to be fetched from the server like new version of apps or something like that.
The GCM service handles all aspects of storing, queuing and delivery of messages to the target Android application running on the target device. It is a completely free service whatever your messaging needs are.
Google Cloud Messaging technology is the new version of the C2DM (cloud to device messaging) technology as the C2DM service has been officially deprecated as of June 26, 2012 which means that C2DM has stopped accepting new users and quota requests. The GCM could be considered as a more efficient implementation of the C2DM technology.
WHAT IS GCM?
Google Cloud Messaging (GCM) is a service that helps developers senddata from servers toandroid applications on Android devices. The service has the ability to send a lightweight message informing the Android application of new data to be fetched from the server.
ADVANTAGES
Reduced battery usage on a device
Improved scalability
Compliancy to industry standards
Using GCM Developers can develop more productive apps
GCM is connected to cloud so developers can get benefits of cloud computing in their apps
GCM is now connected with GAE(Google App Engine)
Used for sending message from Cloud to Device
Supports Push Notifications
DISADVANTAGES
Reduce extra network uses
Consumes less battery
THE GCM SERVICE CHARACTERISTICS
1. It allows 3rd-party application servers to send messages to their Android applications. This is a key feature as you always need your server application to be in direct contact with the mobile application such that you can send messages to the mobile application about new versions for instance.
2. An Android application on an Android device doesn't need to be running to receive messages. The system will wake it up the Android application via Intent broadcast when the message arrives. This is achieved if the application is set up with the proper broadcast receiver and permissions in the AndroidManifest.xml file.
3. The application has full control of how to handle the GCM messages passed to it. For example, the application might post a notification when receiving these messages.
4. It requires devices running Android 2.2 or higher that also have the Google Play Store application installed.
HOW THE GCM WORKS?
There are some key terms and concepts involved in the GCM service and it is very important to have a good knowledge about them. The key terms and concepts of the GCM are divided into two categories:
Components — Thephysical items involved in GCM steps.
Credentials — The IDs that are used in different stages of GCM to achieve the authentication, and to be sure that the message is going to the correct application and the correct Android device.
GCM LIFECYCLE
The usage of the GCM process requires the following phases:
Enabling GCM - An Android application running on a mobile device registers itself to be able to receive messages.
Sending a message - A 3rd-party application server sends messages to the device.
Receiving a message - An Android application receives a message from a GCM server.
Example of Android Application that Uses the GCM
This section will explain an Android application used in the energy-aware smart home project. This app was based on the GCM demo application provided by Google.The details of that application with all of the code snapshots in the next section
The android application architecture is described in Error! Reference source not. It consists of three parts:
1. Application server App (Here called GCM server)
2. GCM client App (the Android App)
3. GCM cloud service
The following is an explanation for the scenario shown in Error! Reference source not found.
1. At the device start up, the installed Android app (GCM client) sends a registration request to the GCM server asking for a registration id. This registration request uses the Google API project ID to identify the Android device that asks for the registration id.
2. The GCM server responds to the previous request and sends the registration id to the Android device. The Android app sends this registration id to server application which stores it in its internal storage.
ARCHITECTURE OF ANDROID APPLICATION THAT USES GCM
In this section, we’ll cover in details the architecture of the Android app that uses the GCM service and also we’ll cover the 3d party application server app.
GCM process flow
As mentioned above the GCM service has three main steps:
o Enabling GCM
o Sending a message
o Receiving a message
Enabling GCM
This is the sequence of events that occurs when an Android application running on a mobile device registers itself into the GCM server to receive messages:
1. The first time the Android application needs to use the messaging service, it sends registration intent to a GCM server.
This registration Intent (com.google.android.c2dm.intent.REGISTER) includes the sender ID, and the Android application ID.
2. If the registration is successful, the GCM server broadcasts a com.google.android.c2dm.intent.REGISTRATION intent which gives the Android application a registration ID.
The Android application should store this ID for later use (for instance, to check on onCreate() if it is already registered).
3. To complete the registration, the Android application sends the registration ID to the application server. The application server stores the registration ID in a database.
Sending a message
For an application server to send a message to an Android application, the following things must be in place:
The Android application has a registration ID that allows it to receive messages for a particular device.
The 3rd-party application server has stored the registration ID.
An API key. It is a key for the application on the application server and it is previously set up in the API key file that exists in the application server app that will be explained later.
Here is the sequence of events that occurs when the application server sends a message:
1. The application server sends a message to GCM servers.
2. GCM servers store the message in case the device is offline.
3. When the device is online, Google sends the message to the device.
Receiving a message
This is the sequence of events that occurs when an Android application installed on a mobile device receives a message:
1. The system receives the incoming message and extracts any data from it, if any.
2. The system passes the key/value pairs to the targeted Android application in a com.google.android.c2dm.intent.RECEIVE Intent as a set of extras.
3. The Android application processes the message
C2DM
• Stands for Cloud to Device Messaging
• Used to send message from cloud to device or application
• Support Push Notification
• C2DM retired and It’s time to GCM (Google Cloud Messaging)
• Part of Google API
Advantages
• Using C2DM Developers can develop more productive apps
• C2DM is connected to cloud so developers can get benefits of cloud computing in their apps
Disadvantages
• Internet connectivity is required
• Limited message size
APPLICATION SERVER APP
The application server used here is the Apache Tomcat v7.0 which is a servlet container that can accept HTTP requests and send HTTP commands to the GCM server. We don’t need to develop a new application server where the GCM Demo server application provided by Google can be used directly. The following steps explain how to use it:
1. From the SDK Manager, install Extras > Google Cloud Messaging for Android Library.
2. This creates a gcm directory under YOUR_SDK_ROOT/extras/google/ containing these subdirectories: gcm-client, gcm-server, samples/gcm-demo-client, samples/gcm-demo-server, and samples/gcm-demo-appengine.
3. You can create a web application from Eclipse and copy the gcm-demo-server app into it as shown below
4. In a text editor or from inside Eclipse, edit the samples/gcm-demo-server/Web Content/WEB-INF/classes/api.key and replace the existing text (if any) with the API key obtained above.
ANDROID PLATFORM ARCHITECTURE
Android operating system consists of a stack of softwarecomponents which can be divided into five sections and four layers. The bottom most layer in android architecture is Linux Kernel.
a)Linux Kernel- This layer provides all the basic systemfunctionality that are typically provided by any operating system like Memory management, Process management and device management like Bluetooth , camera, Wi-Fi, keypad, LED/LCD display etc. This layer also take care of several functions like networking, handling device drivers and interfacing to peripheral devices.
b)Libraries- Second layer on the top of Linux kernel layer isLibraries layer . In this layer there is a set of libraries that also includes open-source Web browser engine WebKit, a very well known library, SQLite database for android which is a used for storing application data and sharing of application data. It also includes libraries to record and play audio and video, SSL libraries responsible for Internet security etc.
c)Android Runtime– This layer is a part of the Librarieslayer. This section provides a very important component of android architecture namely DVM (Dalvik Virtual Machine) which is like a JVM (Java Virtual Machine) specially designed and optimized for Android platform. Thetime interval after which the location of the device is automatically updated.On the other hand user-requested LBS are the services that provide the location coordinates of a device only when it is requested by the user.
GCM DATA COLLECTION
The leverage our time synchronization mechanism (i.e. GCM message type T) to collect our data on the GCM message arrival times. To calculate precise times, use network time protocol (NTP). The GCM message arrival time is defined as the difference between the time the GCM message is initiated from our servers, and the time the client device receives that message. Therefore, in our type T GCM message flow, the difference between the server NTP time of the message initiation, and the client NTP time of the message arrival gives us precise GCM message arrival time for each device. The client devices bounce-back to our type T message with message arrival NTP timestamp, and we calculate per device GCM message arrival times in our server. We evaluate these arrival times to elaborate how GCM performs.In addition to this time data, we also record the network connection type (WiFi or cellular data) of the client devices as well as the cellular service provider in order to test the effects of the connection type and the data service provider.
LOCATION BASED SERVICES
The appearance of different technologies such as wireless networks, Internet, Geographical Information Systems (GIS), Global Positioning Systems (GPS) have introduced a new type of information technology called Location Based Services. Location based services (LBS) is defined as the ability to locate a mobile user geographically and deliver services to the user based on his location. A positioning component is usually needed in LBS application to determine the location of user’s mobile device. Most of the current LBS services do not require users to input location manually, like giving zip code or street name. Instead, user location can be obtained by using some positioning technologies such as satellite positioning, cellular network positioning, WLAN stations. Service providers maintain service servers which offer different kinds of location based services to users and are responsible for processing service requests and sending back request results. Servers calculate positions, search for a route, or search specific information based on user position. Service providers usually do not store and maintain all the informationrequested by users. Instead, content providers are responsible for collecting and storing geographic data, location based information and other related data. Android devices may have one or more of these services available to them. Maps and location based services use latitude and longitude to pinpoint geographic locations. Android provides a Geocoderthat supports forward and reverse geocoding.
ANDROID DEVICE:
The Android application is the main interface via which the user is going to use to receive thepush notifications. The important requirements for developing the application are listed below:
o Client Application [14]: This application is developed using android development studio inconjunction with SDK tools.
o SDK tools [14]: The Android SDK tools compile the code along with any data and resourcefiles. The Android SDK provides the tools and APIs necessary to begin developingapplications on the Android platform using the Java programming language.
o .apk [14]: All the code in a single .apk file is considered to be one application and is the filethat Android-powered devices use to install the application.
o Android OS [14]: Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smart phones and tablet computers. It enables replace andreuse of components.
CONCLUSION
Google Cloud Messaging for Android (GCM) is a free and powerful service that helps developers to send data from servers to their Android applications running on Android-powered devices. The basic concepts of this service with a detailed explanation of the GCM demo application provided by the Android SDK. The GCM service is very promising and it could be considered the most optimized and powerful method for sending messages from servers to the Android devices without the need to have the Android application listens to the server in an endless loop.