Integrate Android SDK

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

Installation

Step 1: Add the mavenCentral() repository to your build file.

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


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

dependencies {
	        implementation("com.suprsend:native:1.0.1")
	}

Initialization

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

class MyApplication : Application() {

    override fun onCreate() {
        SSApi.init(this,"WORKSPACE KEY", "WORKSPACE SECRET")
        super.onCreate()
    }
}

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 code

val ssApi = SSApi.getInstance()

Logging

By default the logs of SuprSend SDK are disabled. We recommend you to enable the SDK logs by setting its value to VERBOSE. You can enable the logs just in debug mode while in development by below condition.

ssApi.setLogLevel(level: LogLevel)
  
if (BuildConfig.DEBUG)
  ssApi.setLogLevel(LogLevel.VERBOSE)

or

//You can send the sdk exception to your crashlytics server
SSApi.setLogger(object : LoggerCallback {
  override fun i(tag: String, message: String) {
    // you will receive sdk info messages here
  }

  override fun e(tag: String, message: String, throwable: Throwable?) {
    throwable ?: return
    //Ex - FirebaseCrashlytics.getInstance().recordException(throwable)
  }
})

Proguard Rules (For release build)

For creating a release build you will need to add these below pro-guard rules:

# SuprSend Sdk
-dontwarn app.suprsend.**
-keep class app.suprsend.**{*;}

# Xiaomi
-keep class app.suprsend.xiaomi.SSXiaomiReceiver {*;}
#SDK has been obfuscated and compressed to avoid class not found error due to re-obfuscation.
-keep class com.xiaomi.**
#If the compiling Android version you are using is 23, you can prevent getting a false warning which makes it impossible to compile.
-dontwarn com.xiaomi.push.**
-keep class com.xiaomi.mipush.sdk.MiPushMessage {*;}
-keep class com.xiaomi.mipush.sdk.MiPushCommandMessage {*;}
-keep class com.xiaomi.mipush.sdk.PushMessageReceiver {*;}
-keep class com.xiaomi.mipush.sdk.MessageHandleService {*;}
-keep class com.xiaomi.push.service.XMJobService {*;}
-keep class com.xiaomi.push.service.XMPushService {*;}
-keep class com.xiaomi.mipush.sdk.PushMessageHandler {*;}
-keep class com.xiaomi.push.service.receivers.NetworkStatusReceiver {*;}
-keep class com.xiaomi.push.service.receivers.PingReceiver {*;}
-keep class com.xiaomi.mipush.sdk.NotificationClickedActivity {*;}
}