allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
.
.
.
dependencies {
implementation 'com.github.human-internet:humanid-android-sdk:0.0.4’
}
Add this code to your AndroidManifest.xml. Make sure that all metadata is fulfilled.
<meta-data
android:name="com.humanid.sdk.applicationIcon"
android:resource="@drawable/ic_app_icon"/>
<meta-data
android:name="com.humanid.sdk.applicationName"
android:value="@string/app_name"/>
<meta-data
android:name="com.humanid.sdk.applicationId"
android:value="YOUR_APP_ID"/>
<meta-data
android:name="com.humanid.sdk.applicationSecret"
android:value="YOUR_APP_SECRET"/>
Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.
LoginManager.getInstance(this).registerCallback(object : LoginCallback {
override fun onCancel() { }
override fun onSuccess(exchangeToken: String) {
//todo: send the exchangeToken to your server
}
override fun onError(errorMessage: String) { }
})
...
..
.
override
fun onActivityResult(requestCode: Int, resultCode:Int, data: Intent?) {
LoginManager.getInstance(this).onActivityResult(requestCode, resultCode,
data)
super.onActivityResult(requestCode, resultCode, data)
}
Add this code to your Activity or Fragment file. We recommend you wrap this in a function that handles the login button.
LoginManager.INSTANCE.getInstance(this).registerCallback(new LoginCallback() {
@Override
public void onCancel() {}
@Override
public void onSuccess(@NotNull String exchangeToken) {
//todo: send the exchangeToken to your server
}
@Override
public void onError(@NotNull String errorMessage) {}
});
...
..
.
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent
data) {
LoginManager.INSTANCE.getInstance(this).onActivityResult(requestCode,
resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
Your Android app should now be integrated with the humanID login.