If you want the SDK to handle users, manage tokens and also render Push
Notifications using Firebase, go for Setup #1. Otherwise, if you want the SDK to
manage only the users or tokens, check Setup #2. In the 2nd setup, you will have
to handle the rendering of notifications yourself.Setup #1This setup helps you quickly get started with Push Notifications using Firebase.
It assumes you have already setup Raven console with a Firebase Integration and
created an event with a Push template as defined here.
Then follow these steps -
Set user on signup/login. You can use any of the following methods to set
user. Note that this will create a user if it does not exists in Raven. If it
exists, it will simply update the user if there is any change.
Set Firebase token after setting up user. This method will first retrieve the
token and associate it with the user that was set earlier.
Copy
Ask AI
FirebaseMessagingService.setFirebaseToken();
To handle Notification clicks, you need to set intent-filter on the activity
that you wish to open. The intent filter action corresponds to the
click_action value in the Push template.
When the user logs out of your app, we need to de-register the device token.
Call logout to logout the user from Raven.
Copy
Ask AI
RavenSdk.logout();
That’s all! The SDK will manage users, tokens and handle rendering of Push
Notifications.Setting user preferences from SDK will be added soon.Setup #2This setup helps you to set user and manage tokens on Raven. It assumes you
already have setup Firebase and are handling the rendering of notifications
yourself. Also, you must setup a Firebase Integration on the console and create
an event with a Push template as defined here. Once done,
please follow the below steps:
Set user on signup/login. You can use any of the following methods to set
user. Note that this will create a user if it does not exists in Raven. If it
exists, it will simply update the user if there is any change.
When you receive a message from Firebase in the onMessageReceived callback,
please update Raven with DELIVERED status. If you have set up Notification
click and dismiss receivers, please update Raven with CLICKED and DISMISSED
statuses respectively. This method takes the Raven notificationId as an
argument. Raven generates a unique notification id and attaches it in the
data payload.
onMessageReceived Callback
Copy
Ask AI
val notificationId = remoteMessage.data["raven_notification_id"]// When notification is deliveredRavenSdk.updateStatus(notificationId, Status.DELIVERED)// When notification is clickedRavenSdk.updateStatus(notificationId, Status.CLICKED)// When notification is dismissedRavenSdk.updateStatus(notificationId, Status.DISMISSED)
When the user logs out of your app, we need to de-register the device token.
Call logout to logout the user from Raven.