Integrate React Native SDK - Android

This document will cover SDK installation and initialization steps for your Android application

Installation

Step 1: Install Package using npm / yarn

npm install @suprsend/react-native-sdk

// for updating sdk to latest version
npm install @suprsend/react-native-sdk@latest
yarn add @suprsend/react-native-sdk

// for updating sdk to latest version
yarn add @suprsend/react-native-sdk@latest

Step 2: Add mavenCentral dependency in project level build.gradle

Inside allprojects repositories, add the below dependency in app build.gradle. This step is required as android sdk is available at mavenCentral repository

allprojects {
  repositories {
    ...
    mavenCentral()
  }
}

Step 3. Add Android SDK dependency inside app level build.gradle
Add following line of code inside dependencies in app build.gradle

dependencies {
  ...
  implementation 'com.suprsend:rn:0.1.10'
}

🚧

Note

If you get any error regarding minSdkVersion please update it to 19 or more


Initialization

Step 1. To integrate SuprSend in your Android app, initialise the Suprsend android sdk in MainApplication.java inside onCreate method and just above super.onCreate() line.

import app.suprsend.SSApi; // import sdk
...
SSApi.Companion.init(this, WORKSPACE KEY, WORKSPACE SECRET); // inside onCreate method just above super.onCreate() line

Replace WORKSPACE KEY and WORKSPACE SECRET with your workspace values. You will get both the tokens from Suprsend dashboard (Settings page -> "API keys" section). For more details, check the documentation on 'Workspaces'.


Step 2. Import SuprSend SDK in your client side Javascript code

import suprsend from "@suprsend/react-native-sdk";

Logging

By default the logs of SuprSend SDK are disabled. You can enable the logs just in debug mode while in development by the below condition.

suprsend.enableLogging(); // available from v2.0.2

// deprecated from v2.0.2
suprsend.setLogLevel(level) 
suprsend.setLogLevel("VERBOSE")
suprsend.setLogLevel("DEBUG")
suprsend.setLogLevel("INFO")
suprsend.setLogLevel("ERROR")
suprsend.setLogLevel("OFF")


What’s Next