1. Manage (Create/Update) your users and their preferences on Raven.
  2. Manage Push tokens on Raven.

Setup

This 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

  1. Setup Firebase

    • Create your Firebase project.
    • Register your app with Firebase.
    • Add a Firebase configuration file.
  2. Add the following in your project gradle:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the following library in your app gradle. Please check the latest version here.
implementation 'com.github.ravenappdev:raven-android-sdk:1.0.6'
  1. Initialize the SDK in Application onCreate.
RavenSdk.initialize(this, YOUR_APP_ID, YOUR_ACCOUNT_API_KEY);
  1. 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.
RavenSdk.setUserMobile(USER_ID, MOBILE);
RavenSdk.setUserEmail(USER_ID, EMAIL);
RavenSdk.setUser(USER_ID, MOBILE, EMAIL);
  1. Set the Firebase device token on Raven.
RavenSdk.setDeviceToken(TOKEN);
  1. 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.
val notificationId = remoteMessage.data["raven_notification_id"]

//When notification is delivered
RavenSdk.updateStatus(notificationId, Status.DELIVERED)

//When notification is clicked
RavenSdk.updateStatus(notificationId, Status.CLICKED)

//When notification is dismissed
RavenSdk.updateStatus(notificationId, Status.DISMISSED)
  1. When the user logs out of your app, we need to de-register the device token. Call logout to logout the user from Raven.
RavenSdk.logout();