Enable Push Notifications in a Salesforce Mobile SDK Android App
-
Add an entry for
androidPushNotificationClientId.-
In res/values/bootconfig.xml (for native apps):
-
In assets/www/bootconfig.json (for hybrid apps):
This example value represents the project number of the Google project that is authorized to send push notifications to Android devices.
Behind the scenes, Mobile SDK automatically reads this value and uses it to register the device against the Salesforce external client app. Each time the user re-opens the app, Mobile SDK automatically renews the registration. This validation allows Salesforce to send notifications to the external client app.
A device becomes unregistered if:
-
The app goes unused for an extended period of time
OR
-
The user logs out of the app
-
-
Create a class in your app that implements
PushNotificationInterface.PushNotificationInterfaceis a Mobile SDK Android interface for handling push notifications.PushNotificationInterfacehas a single method,onPushMessageReceived(Bundle message).In this method you implement your custom functionality for displaying, or otherwise disposing of, push notifications.
-
In the
onCreate()method of yourApplicationsubclass, call theSalesforceSDKManager.setPushNotificationReceiver()method, passing in your implementation ofPushNotificationInterface. Call this method immediately after theSalesforceSDKManager.initNative()call.