Android SDK Integration Guide

Overview

  1. 1.
    Video
  2. 2.
  3. 3.
    Steps
  4. 4.
    Sample

Video

Coming Soon!

Requirements

  • API Level 18 or higher
  • Kotlin
Please update to the latest SDK!

Steps

1. Downloads

1
allprojects {
2
repositories {
3
...
4
maven { url 'https://jitpack.io' }
5
}
6
}
7
.
8
.
9
.
10
dependencies {
11
implementation 'com.github.bluenumberfoundation:humanid-android-sdk:0.0.4’
12
}
Copied!

2. Get Credentials

Get the clientID and clientSecret through the App Registration Form

3. Configuration

Add this code to your AndroidManifest.xml. Make sure that all metadata is fulfilled.
1
<meta-data
2
android:name="com.humanid.sdk.applicationIcon"
3
android:resource="@drawable/ic_app_icon"/>
4
<meta-data
5
android:name="com.humanid.sdk.applicationName"
6
android:value="@string/app_name"/>
7
<meta-data
8
android:name="com.humanid.sdk.applicationId"
9
android:value="YOUR_APP_ID"/>
10
<meta-data
11
android:name="com.humanid.sdk.applicationSecret"
12
android:value="YOUR_APP_SECRET"/>
Copied!

4. Using the SDK in Kotlin

Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.
1
LoginManager.getInstance(this).registerCallback(object : LoginCallback {
2
override fun onCancel() { }
3
4
override fun onSuccess(exchangeToken: String) {
5
//todo: send the exchangeToken to your server
6
}
7
8
override fun onError(errorMessage: String) { }
9
})
10
...
11
..
12
.
13
override
14
fun onActivityResult(requestCode: Int, resultCode:Int, data: Intent?) {
15
LoginManager.getInstance(this).onActivityResult(requestCode, resultCode,
16
data)
17
super.onActivityResult(requestCode, resultCode, data)
18
}
Copied!

5. Using the SDK in Java

Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.
1
LoginManager.INSTANCE.getInstance(this).registerCallback(new LoginCallback() {
2
@Override
3
public void onCancel() {}
4
5
@Override
6
public void onSuccess(@NotNull String exchangeToken) {
7
//todo: send the exchangeToken to your server
8
}
9
10
@Override
11
public void onError(@NotNull String errorMessage) {}
12
13
});
14
...
15
..
16
.
17
@Override
18
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent
19
data) {
20
LoginManager.INSTANCE.getInstance(this).onActivityResult(requestCode,
21
resultCode, data);
22
super.onActivityResult(requestCode, resultCode, data);
23
}
Copied!

6. You Are All Set!

Your Android app should now be integrated with the humanID login.

Sample

See our Github for a full sample to learn more!
  • Warning! To run the example project, clone the repo, and run pod install from the Example directory first.