Adding the SDK and initializing it

Nabla Android SDK installation

⚠️

The Nabla Android SDK is compatible with Android 6 (API Level 23) and higher, so your minSdkVersion should be >= 23.

You also need your compileSdkVersion to be 33 or higher (this doesn't impact your app's minimum Android supported version).

📘

To generate a mobile SDK API key, open your Nabla Console, go to the "Developers" tab, then to the "API keys" section, "Mobile SDK API keys" sub-tab, and click on "Add mobile SDK API key".

Add the dependency

First add Jitpack repository to your build file if it's not already there:

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then add the desired Nabla dependencies in your app's build.gradle:

implementation 'com.nabla.nabla-android:messaging-ui:1.1.3'
implementation 'com.nabla.nabla-android:video-call:1.1.3'
implementation 'com.nabla.nabla-android:scheduling:1.1.3'

Nabla Android SDK requires AndroidX libraries, if your app still relies on support libs, please migrate to androidx.

🧙🏼

Backward compatibility

Nabla Android SDK is using Java features introduced in Android API Level 26. In order to support older versions, i.e. 23 to 26, you need to enable desugaring in your app by setting isCoreLibraryDesugaringEnabled in the gradle file. Check the Java 8+ API desugaring support guide.

Also, to support API 23, you will need to add vectorDrawables.useSupportLibrary true in the defaultConfig section of your build.gradle file, as mentioned in Vector Drawable compat guide.

Initialize the SDK

First provide the SDK API Key in the manifest:

<?xml version="1.0" encoding="utf-8" ?>
<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.your.package"
>
  <application>

    <meta-data
      android:name="com.nabla.sdk.PUBLIC_API_KEY"
      android:value="YOUR_API_KEY"
    />

    <!-- Rest of your manifest -->

  </application>
</manifest>

Then, you need to initialize the SDK with the desired modules (e.g. NablaMessagingModule, NablaSchedulingModule, etc.) before calling any of the API endpoints.
We require doing that when your app starts, in your Application.onCreate method (don't forget to register your MyApp in the manifest, or it will be ignored):

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()

        NablaClient.initialize(
            modules = listOf(
                NablaMessagingModule(), // if you want the messaging feature
                NablaVideoCallModule(), // if you want to add video call capabilities
                NablaSchedulingModule(), // if you want the scheduling feature
            )
        ) { userId: String ->
            // The SessionTokenProvider callback.
            // This is a suspending context: call your server to fetch fresh authentication tokens
            myServerService.getAuthTokens(userId)
        }
    }
}

📘

Check the authentication guide to know more about the SessionTokenProvider