Get started with Android SDK
Latest release: Version 1.34.0 (Changelog)
Requirements
- AndroidX
- API level 21 (Android 5.0) and above (distribution stats)
- Kotlin 1.7.10 or higher
Resources
- Integration Sample (Kotlin) — idensic-mobile-sdk-sample-android
- Integration Sample (Java) — idensic-mobile-sdk-sample-android-java
Installation
- Add the Sumsub maven repository to the repositories section in your
build.gradle
file.
repositories {
maven { url "https://maven.sumsub.com/repository/maven-public/" }
}
- Add the following dependencies to your
build.gradle
file.
dependencies {
// SumSub core
implementation "com.sumsub.sns:idensic-mobile-sdk:$latestVersion"
// Video Identification module
implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:$latestVersion"
// eID module
implementation "com.sumsub.sns:idensic-mobile-sdk-eid:$latestVersion"
}
Initialization
Attention
Make sure you have configured your verification level and access token before initializing the SDK.
The following are initialization examples.
// use the 'accessToken' that you generated on your backend
val accessToken = "..."
val tokenExpirationHandler = object : TokenExpirationHandler {
override fun onTokenExpired(): String? {
// Access token expired
// get a new one and pass it to the callback to re-initiate the SDK
val newToken = "..." // get a new token from your backend
return newToken
}
}
val snsSdk = SNSMobileSDK.Builder(this)
.withAccessToken(accessToken, onTokenExpiration = tokenExpirationHandler)
.withLocale(Locale("en"))
.build()
snsSdk.launch()
// use the 'accessToken' that you generated on your backend
String accessToken = "...";
TokenExpirationHandler tokenUpdater = () -> {
// Access token expired
// get a new one and pass it to the callback to re-initiate the SDK
String newAccessToken = "..."; // get a new token from your backend
return newAccessToken;
};
SNSMobileSDK.SDK snsSdk = new SNSMobileSDK.Builder(requireActivity())
.withAccessToken(accessToken, tokenUpdater)
.withLocale(new Locale("en"))
.build();
Dismissal
By default, once the applicant is approved, the SDK will be dismissed in 3 seconds automatically. You can adjust this time interval or switch the automatic dismissal off by setting the value of zero.
snsSdk.withAutoCloseOnApprove(0)
Also, in case you need to close the SDK programmatically.
snsSdk.dismiss()
Configuration
Applicant Data
If it is required, you can provide an email and/or a phone number that will be initially assigned to the applicant.
val snsSdk = SNSMobileSDK.Builder(this)
...
.withConf(SNSInitConfig(email = "...", phone = "..."))
.build()
snsSdk.launch()
SNSMobileSDK.SDK snsSdk = new SNSMobileSDK.Builder(requireActivity())
...
.withConf(new SNSInitConfig("...", "...", null))
.build();
Preferred Documents
For IDENTITY*
steps, it is possible to specify the preferred country and document type to be selected automatically, thereby bypassing the DocType Selector screen.
Note that the provided parameters will be applied only if the corresponding combination of country
and idDocType
is allowed at the step according to the level configuration.
val snsSdk = SNSMobileSDK.Builder(this)
...
.withPreferredDocumentDefinitions(mapOf(
"IDENTITY" to SNSDocumentDefinition(idDocType = "DRIVERS", country = "USA")
))
.build()
SNSMobileSDK.SDK snsSdk = new SNSMobileSDK.Builder(requireActivity())
...
.withPreferredDocumentDefinitions(Map.of(
"IDENTITY", new SNSDocumentDefinition("DRIVERS", "USA")
))
.build();
Video identification
The VideoIdent is an optional module that is required only if you are going to use the Video identification during the verification flow.
To enable the module, add the following dependency to your build.gradle
file.
dependencies {
// Video Identification module
implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:$latestVersion"
}
eID
The eID is an optional module that is required only if you are going to use the eID during the verification flow.
To enable the module, add the following dependency to your build.gradle
file.
dependencies {
// eID module
implementation "com.sumsub.sns:idensic-mobile-sdk-eid:$latestVersion"
}
NFC
Starting from MDSK 1.34.0, the NFC is an optional module that is required only if you are going to use the NFC during the verification flow.
To enable the module, add the following dependency to your build.gradle
file.
dependencies {
// NFC module
implementation "com.sumsub.sns:idensic-mobile-sdk-nfc:$latestVersion"
}
Action Flow
In order to run the SDK in applicant action mode, you need to create an applicant flow of Applicant actions
type in the dashboard and specify its name as the flowName
initialization parameter.
Also, make an access token not only with the userId
parameter, but with the externalActionId
one as well.
Aside from the notes above, you manage the SDK the same way that you do with regular flows, the only difference is in how you get the action results.
File selection in gallery
You can specify the type of file requested from the gallery by overriding the resource string.
<string name="sns_gallery_type">*/*</string>
Users can preview PDF files on Android devices running 5.0 Lollipop and higher.
Low-light performance for our liveness detection
The SDK can operate using screen light in low-light conditions. The application must have additional permissions to change screen brightness. Accordingly, you can request that the applicant opens settings and adds the application to their device’s trusted list.
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
Obfuscation
The Sumsub MobileSDK contains necessary proguard rules. You don't need to add it manually.
Make sure you have disabled R8 full mode; in the gradle.properties
, add the following line:
android.enableR8.fullMode=false
Reduce SDK size
You can reduce the size of your application's release build by removing TensorFlow library binaries, which will save about 7 MB, depending on the supported architectures.
Note that removing these libraries may affect some features of the Sumsub SDK:
- Lower face detection accuracy in some cases.
- The client-side photo quality detector will be disabled.
- Automatic documents capture will be disabled.
To remove TensorFlow libraries from the resulting APK (or AAB), add the following code to the application's build.gradle
file:
android {
// excludes heavy TF *.so files from the apk.
packagingOptions {
exclude 'lib/**/libtensorflowlite_jni.so'
}
Updated 2 days ago