Skip to content

Android

This guide provides step-by-step instructions on integrating the IDV SDK into an Android application. It covers initialization, API configuration, workflow setup, and starting the ID verification process.

Before getting started, make sure you have installed the SDK.

Initialize

In your MainActivity.kt, initialize the SDK with the required modules:

import com.regula.idv.api.IdvSdk
import com.regula.idv.docreader.DocReaderModule
import com.regula.idv.face.FaceModule
import com.regula.idv.api.config.InitConfig

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val config = InitConfig(listOf(DocReaderModule(), FaceModule()))   // you can use both DocReader and Face modules, or only one when it's not required by the workflow
        IdvSdk.instance().initialize(context, config) {
            // Handle initialization result
        }
    }
}

Configure API Settings

Before using the SDK, configure the API connection. There are three ways to configure the API connection:

Using credentials

import com.regula.idv.api.config.CredentialsConnectionConfig

val URL = "https://..."
val USER_NAME = "your_username"
val PASSWORD = "your_password"

IdvSdk.instance().configure(context, CredentialsConnectionConfig(URL, USER_NAME, PASSWORD, IS_SECURE)) {
    it.onSuccess {
        // handle success
    }
    it.onFailure { exception ->
        // handle errors
    }
}

Using token

Use this method when you have a URL with a predefined authentication key. The result will provide a list of workflow IDs that you can perform.

import com.regula.idv.api.config.TokenConnectionConfig

val URL = "https://.../mobile?authorization=Token%20tr-pn7u6f5wizj9l7fnx4nzu8pqrnlwr&sessionId=68a72388660070d96275a8c2"

IdvSdk.instance().configure(context, TokenConnectionConfig(URL)) {
    it.onSuccess { workflows ->
        // handle success
    }
    it.onFailure { exception ->
        // handle errors
    }
}

Using API key

import com.regula.idv.api.config.ApiKeyConnectionConfig

val URL = "https://..."
val API_KEY = "yprpwttipracqerersuzzrs_fbptvhtoczfjbx9azn8w3lzioddacyw3slfvoq3"

IdvSdk.instance().configure(context, ApiKeyConnectionConfig(URL, API_KEY)) {
    it.onSuccess {
        // handle success
    }
    it.onFailure { exception ->
        // handle errors
    }
}

Prepare and Start ID Verification Workflow

Prepare workflow before starting verification

import com.regula.idv.api.config.PrepareWorkflowConfig

val workflowId = "your_workflow_id"
IdvSdk.instance().prepareWorkflow(context, PrepareWorkflowConfig(workflowId)) {
    it.onSuccess {
        // handle success
    }
    it.onFailure { exception ->
        // handle errors
    }
}

Start workflow with default parameters when ready

IdvSdk.instance().startWorkflow(context) {
    it.onSuccess { workflowResult ->
        Log.d("IDV", "sessionId: ${workflowResult.sessionId}")
    }
    it.onFailure { exception -> 
        // handle errors
    }
}

Set up metadata before starting workflow

import com.regula.idv.api.config.StartWorkflowConfig

val metadata = JSONObject()
metadata.put("key1", "value1")
val config = StartWorkflowConfig.Builder()
    .setMetadata(metadata)
    .build()
IdvSdk.instance().startWorkflow(context, config) {
    it.onSuccess { workflowResult ->
        Log.d("IDV", "sessionId: ${workflowResult.sessionId}")
    }
    it.onFailure { exception -> 
        // handle errors
    }
}

Start workflow with a specific language

import com.regula.idv.api.config.StartWorkflowConfig

val config = StartWorkflowConfig.Builder()
    .setLocale("de")
    .build()
IdvSdk.instance().startWorkflow(context, config) {
    it.onSuccess { workflowResult ->
        Log.d("IDV", "sessionId: ${workflowResult.sessionId}")
    }
    it.onFailure { exception -> 
        // handle errors
    }
}

Best Practices and Troubleshooting

  • Ensure all necessary dependencies are included in build.gradle.kts.
  • Handle API failures by checking the workflowResult and exception callbacks.
  • Grant camera permissions before starting the workflow.
  • Use proper configuration when establishing a connection to the Platform.