Skip to main content

Quick Start: Android

Minimal Requirements for SDK setup.

  1. Add the Huma SDK Maven repository to your project: Open your settings.gradle.kts file and add the following code to the dependencyResolutionManagement section:
maven {
// TODO: wil be replaced with the actual public url
url = uri("https://maven.pkg.github.com/huma-engineering/huma-android-sdk")
credentials {
username = "***"
password = "***"
}
}

Note: Replace *** with your GitHub username and GitHub token.

  1. Add the Huma SDK dependency to your project: Open your build.gradle.kts file and add the following code to the dependencies section:
dependencies {
// Other dependencies...

// Install complete SDK bundle
implementation("com.huma.sdk:bundle:2.x.x")

// Or install individual modules
implementation(platform("com.huma:android-sdk-bom:2.x.x"))
implementation("com.huma.sdk:appkit")

/* Plugin dependencies */
// Replace with the actual Plugin modules
implementation("com.huma.sdk:plugins-...")
// Replace with the actual Plugin device module
implementation("com.huma.sdk:plugin-device...")
// Replace with the actual Plugin Huma module
implementation("com.huma.sdk:plugin-module...")
// Replace with the actual Plugin widget module
implementation("com.huma.sdk:plugin-widget...")
}
  1. Add Huma gradle plugin to your project:
plugins {
id("com.huma.sdk.gradle-plugin") version "1.0.0"
}
  1. Download the huma-sdk-config.json file from the Huma workspace and add it to your project's app folder.
    1. Log in to the Huma Workspace.
    2. Download the huma-sdk-config.json file.
    3. Add it to your project directory.

config file place

  1. Initialize Huma SDK in your Application class or using AppStartup library:
context.installHumaSdk()
  1. If you will use Huma SDK as an integration to your project you need to create AuthenticationProvider
class MyAuthenticationProvider : AuthenticationProvider {
override suspend fun onTokenRequired(reason: Reason): AuthData? {
// do a call to your backend to obtain huma session
}
}

Where AuthData is a data class that contains the auth token and refresh token.

data class AuthData(
val authToken: String,
val refreshToken: String,
)

Then register this class in SDK initializer

context.installHumaSdk {
sdk {
authKit {
authProvider(MyAuthenticationProvider())
// or
autoInitAuthProvider(MyAuthenticationProvider())
}
}
}

If AuthenticationProvider is registered with autoInitAuthProvider method, SDK will automatically call onTokenRequired on the app start.

In on other case, when it's registered with authProvider method, you should do this call when your are ready to authorise the user.

HumaAuthKitManager.getInstance().authorize()
  1. To get started with you screen, you can use the following code:
val humaAppKitManager = HumaAppKitManager.getInstance(context)
val screen = humaAppKitManager.findScreen("screenId")

After this steps you can start using Huma SDK in your project. To get more information about the configuration options please refer to the Getting Started section.