Subscribing for GCM Push Notifications

(Optional) Subscribe to get GCM push notifications.

To enable GCM push notification for an Android application:
  1. See Enabling the GCM Service.
  2. Configure SCC for server side configuration to receive GCM push notification. For more information on configuring native notification, see Configuring Native Notifications in Sybase Control Center for Sybase Unwired Platform.
You can obtain the sender ID from the client application configured in SCC by invoking getConfigProperty() with the property name d:AndroidGcmSenderId. Using this sender ID, you should register GCMRegistrar.register("<sender ID>").
Note:
  • On-premise - Obtain the sender ID from the property d:AndroidGcmSenderId.
  • On cloud - Provide the sender ID from the application directly.

Syntax

In the onRegistered callback of GCMBaseIntentService, set the GCM registeration ID obtained from the google to the property d:AndroidGcmRegistrationId.

       @Override
       protected void onRegistered(Context arg0, String registrationId) 
       {
        try
         {
		    public static AppSettings appSettings = new AppSettings(clientConnection);
 		   HashMap<String, String> fullConfig = new HashMap<String, String>();
		    fullConfig.put("d:AndroidGcmRegistrationId", registrationId);
			appSettings.setConfigProperty(fullConfig);
		 }
        catch(SMPException e)
        {
    		Log.i("tag", "Error from update settings " + e.getMessage() + "Error code" + e.getErrorCode());
   		 e.printStackTrace();
   	 }
.	}

Usage

Notifications can be sent to the device for the push endpoint obtained from the getPushEndPoint (). Notifications sent will be received to onMessage call back of GCMBaseIntentService ().