Push Notification
This section covers how to setup push notification in React Native.
Enabling Push Notification in SDK
Set enablePush
to true
during SDK initialization. More details about SDK initialization can be found
here
Native setup
Step 1: Add required permissions
Add the following permission to android app AndroidManifest.xml
. This allows the app to receive push notifications
Step 2: Firebase push messaging handling service
By default SDK takes care of push token fetch and notification handling once app gets the permission to post notification.
In case the app has registered its own Firebase message service class (FirebaseMessagingService
) for handling push tokens,
SDK needs to be notified of the new token and any push notification received from Castled platform.
Folow these instructions
if you already have a FirebaseMessagingService
registered.
Step 3: Notification default configs
You can also configure default values for Notification Channels and Notification Icons. Please find the instructions here
Requesting Push Notification Permission
Following SDK method can be used by the app to fetch user permission for showing push notifications. User will be shown the native notification permission dialog based on the mobile platform he is on.
Push Notification Events Listener
App can listen to push notification events by registering a listener. This is useful when you want to override the default click actions implemented by the SDK with your own custom implementations.
Currently the following push events as supported:
- Notification Received
- Notification Clicked
- Notification Dimissed
Please find the sample code snippet below
If the App is handling the push notification click actions itself, please
disable the default url handling by the SDK by setting skipUrlHandling
to
true
in the SDK configs during initialization.