Enabling GCM Push Notifications

(Optional) Subscribe to get GCM (Google Cloud Messaging) push notifications.

To enable GCM push notification for an Android application:

  1. Enable the GCM service in Google, see Android developer Web site at: http://developer.android.com/google/gcm/gs.html#gcm-service.
  2. Configure Management Cockpit for server-side configuration to receive GCM push notification.
  3. Obtain the sender ID, configured in the Management Cockpit from the client application.
    //use the clientConnection object initialized in the “Initializing An Application -> Creating and Initializing the Client Connection” section.
    AppSettings appSettings = new AppSettings(clientConnection);
    String senderID = (String) appSettings.getConfigProperty(“d:AndroidGcmSenderId”);
    
  4. Use the sender ID to register with the GCM server and obtain the registration ID. For more information on how to build GCM enabled application, see http://developer.android.com/google/gcm/client.html.
  5. Send the registration ID obtained from the GCM server to the SAP Mobile Platform Server.
    HashMap<String, String> registrationSetting = new HashMap<String, String>();
                   registrationSetting.put("d:AndroidGcmRegistrationId", registrationId);  //registrationId obtained from the previous step.
                      appSettings.setConfigProperty(registrationSetting);
    
Next
Configuration is complete and now the client application can obtain the push notifications.

Obtain the SAP Mobile Platform push end-point by using the AppSettings.getPushEndPoint(). This endpoint can be used to subscribe for push notifications from the back end.