Setup

Nabla Android SDK Installation & Quick Start

Integrating the SDK

The Nabla Messaging UI SDK is compatible with Android 8 (API Level 23) and higher.

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

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

Then add Nabla's dependency in your app's build.gradle:

implementation 'com.nabla.nabla-android:messaging-ui:1.0.0-alpha06'

Nabla Messaging 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.

Setup

To setup the SDK, first provide your API key in the app 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 before calling any of the API. We recommend doing that in your Application.onCreate method:

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

        NablaClient.initialize()
    }
}

📘

This part of the documentation assumes you're using the NablaClient.getInstance() singleton. If you want to use your own instance (via your own DI mechanism), you can check the manual injection guide.

Authenticate the app user

Once a user is logged-in into your app, you need to authenticate them against the Nabla SDK so that they can securely access their conversations.

You need to call authenticate with:

  • The id of the user: it should be stable as long as the user didn't change (it will be passed as parameter to the SessionTokenProvider)
  • A SessionTokenProvider: A function that will be called when the Nabla SDK needs to authenticate the user. It should return an accessToken and a refreshToken from your backend.
    See server side documentation for more details.
launch {
    NablaClient.getInstance().authenticate(
        userId = yourUserId,
        sessionTokenProvider = { userId ->
            // this is a suspending context: call your server to fetch fresh authentication tokens
            myServerService.getAuthTokens(userId)
        }
    )
}

Make sure you call authenticate before calling any other method of the SDK, otherwise a NablaException.Authentication.NotAuthenticated will be returned as Result.

Your first start

You can now launch your app to ensure everything goes well and you're ready to start integrating UI components.


Did this page help you?