Verification flow
Start the SDK
When the user starts a verification, get a new sdkConfiguration from your backend, and call MicroblinkPlatform.startVerification from the main thread:
MicroblinkPlatform.startVerification(this, createConfiguration(sdkConfiguration))
private fun createConfiguration(sdkConfiguration: String) = MicroblinkPlatformConfiguration(
engine = EngineConfiguration(
service = ServiceSettings(sdkConfiguration = sdkConfiguration)
),
resultListener = resultListener,
ui = UiConfiguration(
// customize the UI if needed
),
)
The SDK opens its own activity, and runs the steps of the workflow, in the order that the Platform returns them.
Only one verification can run at a time.
startVerification throws an IllegalStateException if a verification is already running.
Handle the outcome
The SDK reports the outcome through MicroblinkPlatformResultListener.
Exactly one of its methods is called for each verification, on the main thread, after the user leaves our screens:
private val resultListener = object : MicroblinkPlatformResultListener {
override fun onVerificationFinished(outcome: SessionOutcome.Verification) {
when (outcome.state) {
VerificationState.Accept -> { /* Handle successful verification */ }
VerificationState.Reject -> { /* Handle failed verification */ }
VerificationState.Review -> { /* Handle verification that requires manual review */ }
}
// use the transaction ID if needed
val transactionId = outcome.transactionId
}
override fun onVerificationCanceled(outcome: SessionOutcome.Canceled) {
// Handle verification cancellation
}
override fun onVerificationFailed(transactionId: String?, error: EngineError) {
// Handle a verification that ended with an error
}
}
onVerificationFinishedis called when the verification reached a verdict, and the user closed the result screen.onVerificationCanceledis called when the user left the verification before it finished.onVerificationFailedis called when the verification ended with an error that the user can't retry, and they closed the error screen.transactionIdisnullif the verification couldn't start at all.
Errors that the user can retry, such as a lost connection or a blurry scan, are handled on our screens, and don't reach your listener.
tip
Lifecycle
- Each
sdkConfigurationbelongs to one transaction. To start another verification, get a new one from your backend. - If the app's process is killed during a verification, the verification can't continue. Create a new transaction and start over.