Skip to end of metadata
Go to start of metadata

This section describes simple steps required to create an application to support Google Cloud Messaging in Android device. For more information on creating app to support GCM, refer to Set up a GCM Client App on Android.

  1. Register the client application.
  2. Get a configuration file from Google Developer console to add to your project. For more information, refer to Get a configuration file.
  3. Add the configuration file to your project. For more information, refer to Add the configuration file to your project.
  4. Setup Google play services.
  5. Edit your application's Manifest.
  6. Check for Google Play Services APK.
  7. Obtain a registration token.

For GCM to work the following classes are added in the Manifest.xml file as service. The Manifest.xml file calls the methods included in their respective classes when GCM functionality is invoked.

  1. RegistrationIntentService - This class handles the registration of the client application with the GCM connection server. When an app registers, it receives a registration token and sends it to the app server (the WRTC gateway) using the method sendRegistrationToServer(). The client app stores a Boolean value indicating whether the registration token has been sent to the server.
  2. MyGCMListenerService - This class extends the GCMListenerService and implements the onMessageReceived() callback when a GCM message is received. When this callback is invoked, the application calls sendNotification() to create and show a notification on the device.
  3. MyInstanceIdListenerService - This class extends the InstanceIDListenerService and implements the onTokenRefresh() callback which is invoked when the registration token gets refreshed.

For more information on Google Cloud Messaging feature, refer to Google Cloud Messaging Support in WRTC.