Quick Start: Android
Minimal Requirements for SDK setup.
- Add the Huma SDK Maven repository to your project: Open your
settings.gradle.kts
file and add the following code to thedependencyResolutionManagement
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.
- Add the Huma SDK dependency to your project: Open your
build.gradle.kts
file and add the following code to thedependencies
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...")
}
- Add Huma gradle plugin to your project:
plugins {
id("com.huma.sdk.gradle-plugin") version "1.0.0"
}
- Download the
huma-sdk-config.json
file from the Huma workspace and add it to your project's app folder.- Log in to the Huma Workspace.
- Download the huma-sdk-config.json file.
- Add it to your project directory.
- Initialize Huma SDK in your Application class or using AppStartup library:
context.installHumaSdk()
- 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()
- 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.