(Optional) Subscribe to get GCM push notifications.
To enable GCM push notification for an Android application:
- See Enabling the GCM Service.
- Configure SCC for server side configuration to receive GCM push
notification. For more information on configuring native notification, see
Configuring Native Notifications in SAP Control Center
for SAP Mobile 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();
}
. }