Android
Sample Project
You can find the sample project for sample code for Android Integration.
Requirements:
The minSdkVersion must be 21 or higher and targetSdkVersion should be 31 or higher for the application.
Latest Stable Version
The current latest release of IDWise SDK.
Latest SDK Version |
---|
IDWise 4.9.2 |
Step 1: Add IDWise SDK dependency
In order to use IDWise SDK you need to add the following sections to thebuild.gradle
file
- Add
multiDexEnabled true
anddataBinding true
in these sections:
android {
...
defaultConfig {
...
multiDexEnabled true
}
buildFeatures {
...
dataBinding true
}
}
- If you are using a version of IDWise SDK older than 4.5.0 then add the following reference to your repositories section.
repositories {
maven { url 'https://mobile-sdk.idwise.ai/releases/' }
}
- If you are using a version of IDWise SDK later than 4.5.0 then just double check that
mavenCentral()
is added in your repositories, which is added by default if you create a new Android Project.
repositories {
...
mavenCentral()
}
- Add the following dependency inside your
dependencies
section:
implementation 'com.idwise:android-sdk:VERSION_NUMBER'
For example, to use version x.y.z of IDWise SDK, you would do the following:
dependencies {
...
implementation 'com.idwise:android-sdk:x.y.z'
}
If you use Proguard
You need to update your build as follow:
// generate release apk buildTypes { release { signingConfig signingConfigs.release proguardFile '../proguard.pro' minifyEnabled true //enableR8 code Shrinking & Obfuscation shrinkResources true } }
And add the following file to your app proguard.pro, in case the first simpler configuration doesn’t work, please try the second more comprehensive configuration in proguard-2.pro
Step 2: Initialize IDWise SDK
The first step to use IDWise SDK is to initialize it in your Activity or Fragment as follows:
IDWise.initialize(clientKey, IDWiseSDKTheme.SYSTEM_DEFAULT) {
error: IDWiseSDKError? -> error?.printStackTrace()
}
initialize
method takes two parameters:
clientKey
: is a key provided to you by IDWise to authenticate your app with IDWise backend.theme
: is an enum to indicate the theme (Light or Dark) to use for IDWise's UI. it accepts the following values:IDWiseSDKTheme.SYSTEM_DEFAULT
: follows the system theme.IDWiseSDKTheme.LIGHT
: to force the theme to be in light mode.IDWiseSDKTheme.DARK
: to force the theme to be in dark mode.
Step 3: Start a new journey
Once the SDK is initialized, it becomes ready to start an ID verification journey flow. To commence the flow, the SDK offers a startJourney
method, as demonstrated below.
IDWise.startJourney(
context,"<FLOW_ID>","<REFERENCE_NUMBER>","en",journeyCallback
)
This method takes the following parameters:
flowId
: (also called Journey Definition ID): This is a unique identifier that identifies your journey flow. IDWise shares this with you when you register to use IDWise system.referenceNo
: (Optional) This parameter allows you to attach a unique identifier (such as a reference number) with the user undergoing the current journey. It's beneficial for connecting the journey to the user and/or the application that initiated it. You will receive this reference number in the webhook request.locale
: (Optional)This refers to the ISO code representing the desired language for the user interface components. Please reach out to IDWise Support for the list of available languages.IDWiseSDKCallback
: This is an implementation of an interface that consists of various callback events. These events are:
Journey Callbacks
val journeyCallback = object : IDWiseSDKCallback {
override fun onJourneyStarted(journeyInfo: JourneyInfo) {
Log.d("IDWiseSDKCallback", "onJourneyStarted")
}
override fun onJourneyCompleted(journeyInfo: JourneyInfo,isSucceeded: Boolean) {
Log.d("IDWiseSDKCallback", "onJourneyCompleted")
}
override fun onJourneyResumed(journeyInfo: JourneyInfo) {
Log.d("IDWiseSDKCallback", "onJourneyResumed")
}
override fun onJourneyCancelled(journeyInfo: JourneyInfo?) {
Log.d("IDWiseSDKCallback", "onJourneyCancelled")
}
override fun onError(error: IDWiseSDKError) {
Log.d("IDWiseSDKCallback", "onError ${error.message}")
}
})
Journey call-backs are detailed below:
onJourneyStarted
: This event is triggered when a user's journey begins. It serves to notify your application that the process has been initiated. Useful for logging or implementing any preparatory actions necessary for the journey.onJourneyResumed
: This event is triggered when a user's journey begins. It serves to notify your application that the process has been initiated. Useful for logging or implementing any preparatory actions necessary for the journey.onJourneyCompleted
: This callback is activated upon the completion of a user's journey. It signifies that the user has successfully navigated through all steps and finished the process. This is typically where you would implement any code required to handle the completion of the journey.onJourneyCancelled
: This is applicable for simple SDK, and not applicable for the dynamic SDK.onError
: This event is invoked when an error occurs at any point during the journey. It allows your application to respond to any unexpected issues, ensuring smooth error handling and user experience. Bellow all possible errors.
Resuming a Journey
If you want to resume an unfinished journey, you can do so as below:
IDWise.resumeJourney(
context,"<FLOW_ID>","<JOURNEY_ID>","en",journeyCallback
)
This method takes the following parameters:
flowId
: (also called Journey Definition ID): This is a unique identifier that identifies your journey flow. IDWise shares this with you when you register to use IDWise system.journeyId
: This is a unique identifier that identifies your journey and it can be used to resume. This is received in the implementation ofjourneyCallback
interface inonJourneyStarted
method when you started the journey the first time.locale
: (Optional)This refers to the ISO code representing the desired language for the user interface components. Please reach out to IDWise Support for the list of available languages.IDWiseSDKCallback
: The implementation of the callback is in the preceding section.
Common Error Codes and Their Causes
IDWiseErrorCode | Int Value | Cause |
---|---|---|
INVALID_PARAMETERS | 11 | clientKey is invalid or empty. |
SDK_NOT_INITIALIZED | 22 | Either You haven’t Called the IDWise.initialize or you haven’t waited for a callback |
WRONG_CREDENTIALS | 33 | clientKey is incorrect |
INTERNAL_ERROR | 44 | Internal Error occurred while processing the request |
Updated 2 months ago