Android Push Notification support
Oracle CX Core SDK enables tracking of application opening by a click on push notification message automatically or manually based on the configurations.
Tracking push notification events automatically
SDK provides several ways for configuring the app to track the push notification events automatically:
- Creating a notification by using ORANotification class.
- Passing the required key value pair to intent extra info using Android push notification.
- Creating a notification through Firebase Cloud Messaging setting required data pair.
General requirements
To enable automatic tracking of notification events you should:
- Set PUSH_AUTO_ENABLED the config value to "true" as below.
Add below line in oracle.json
- Have "ora_notification" key as an intent extra value for push notification activity.
Creating a notification by using ORANotification class.
Example using ORANotification
Build your notification event using ORANotification class, which will add the required key to event data automatically.
Passing the required key value pair to intent extra info using Android push notification.
Example using Android Notification
Build your notification event using android notification compat builder and pass the required "ora_notification" key to intent extra params.
Or you can create your own chanel id for the devices with target API 27 (Android 8 Oreo) or above.
Creating a notification through Firebase Cloud Messaging setting required data pair.
Example using Firebase Messaging Service (FCM)
FCM example for application in foreground
When app is in foreground the FirebaseMessagingService's onMessageReceived method is called thus you can pass the required key value pair to your intent manually in the method.
And when automatics is enabled the SDK will be able to track your notification and send event when your notification is clicked.
FCM example for application in background or killed
When your app is in background the FirebaseMessagingService's onMessageReceived isn't called and you need to pass specific key value pair via request body 'data' field or using Firebase console "Additional Parameters" fields.
POST request example
Firebase console configuration example
There are three ways to send notification from Firebase (console and by HTTP request):
- application package name - pushes notification to all apps with the package
- specific application token in device - pushes notification only to specific device
- specific topic - pushes notification to the devices which subscribes that topic
For each case you need to send the key value pair specified by Oracle CX Core SDK:
Tracking push notification events manually
The triggerNotificationEvent method can be used to manually track whether the application was opened by clicking on a notification event. The call can be put in onActivityStarted method where users can get the required info from intent extras and send in the event using customData.