Configuration
The Android SDK is configured through MicroblinkPlatformConfiguration, which you pass to MicroblinkPlatform.startVerification:
MicroblinkPlatform.startVerification(
activity = this,
configuration = MicroblinkPlatformConfiguration(
engine = EngineConfiguration(
service = ServiceSettings(sdkConfiguration = "...")
),
resultListener = ...,
)
)
See the quick start for a full integration example.
Everything else about the verification, such as the steps and their order, comes from the workflow and the transaction that your backend created.
Configuration object
MicroblinkPlatformConfiguration(
engine = EngineConfiguration(
service = ServiceSettings(
sdkConfiguration = "...",
retryPolicy = NetworkRetryPolicy(), // optional
),
),
resultListener = ...,
ui = UiConfiguration(), // optional
cardScanResultListener = ..., // optional
)
Required fields
engine
MicroblinkPlatformConfiguration(
engine = EngineConfiguration(
service = ServiceSettings(sdkConfiguration = sdkConfiguration)
),
...
)
What the SDK needs to run the transaction that your backend created.
EngineConfiguration comes from the engine, microblink-platform-engine.
EngineConfiguration also has an appearance field, for the scanning screens of apps that use the engine alone.
Our screens ignore it, and color the scanning screens with ui instead.
service.sdkConfiguration
ServiceSettings(
sdkConfiguration = sdkConfiguration,
)
The sdkConfiguration value that your backend received when it created the transaction with POST /api/v2/transaction.
Pass it as it is; don't parse or modify it.
Read Backend.
It authorizes the SDK for this one transaction, so treat it as a secret, and don't log it.
service.retryPolicy
ServiceSettings(
sdkConfiguration = sdkConfiguration,
retryPolicy = NetworkRetryPolicy(maxAttempts = 5, retryDelayMillis = 500),
)
Optional. How often the SDK retries a request that failed or that the Platform couldn't process yet, before it reports an error:
maxAttempts: the maximum number of attempts for each step. Retries and polling share this budget. Default:5.retryDelayMillis: how long the SDK waits, in milliseconds, before a retry, and before polling again when the Platform doesn't name a delay. Default:500.
The default is a good fit for most apps.
resultListener
MicroblinkPlatformConfiguration(
...
resultListener = object : MicroblinkPlatformResultListener {
override fun onVerificationFinished(outcome: SessionOutcome.Verification) { ... }
override fun onVerificationCanceled(outcome: SessionOutcome.Canceled) { ... }
override fun onVerificationFailed(transactionId: String?, error: EngineError) { ... }
},
)
The listener that receives the outcome of the verification. See Listener methods.
Optional fields
ui
UiConfiguration(
colorScheme = lightColorScheme(
primary = Cobalt,
surface = Color.White,
),
typography = MicroblinkPlatformTypography.default(myFontFamily),
scannerTypography = ScannerTypography(
scanningInstructions = TextStyle(fontFamily = myFontFamily, fontSize = 16.sp),
),
images = MicroblinkPlatformImages(
home = R.drawable.my_home,
verificationSuccess = R.drawable.my_success,
verificationFail = R.drawable.my_fail,
verificationReview = R.drawable.my_review,
cameraPermission = R.drawable.my_camera_permission,
),
buttonShape = CircleShape,
)
How our screens look:
colorScheme: anandroidx.compose.material3.ColorScheme. Itsprimary,onPrimary,surface, andonSurfacecolors also color the document scanning, card scanning, and face capture screens.typography: aMicroblinkPlatformTypography, with a text style for each kind of text on our screens. It doesn't change the fonts of the scanning screens.scannerTypography: aScannerTypography, with the text styles of the document scanning, card scanning, and face capture screens. Optional; anullstyle keeps the scanning SDK's own.images: the images on the home, result, and camera permission screens.buttonShape: the shape of every button on our screens, including those in dialogs.
Read more about how to customize your Android SDK integration.
cardScanResultListener
MicroblinkPlatformConfiguration(
...
cardScanResultListener = MicroblinkPlatformCardScanResultListener { card ->
// card.cardNumber, card.expiryDate, card.owner, card.cvv
},
)
Receives the card that a card scanning step read. It's called on the main thread, at most once for each verification, as soon as the Platform accepts the card. The verification continues after it.
CardScanResult contains:
cardNumber: the full card number.expiryDate: aCardDate, withday,month, andyear.owner: the card owner, if the card shows one.cvv: the CVV, if the card shows one.
The result is complete, even if the workflow masks the card data that's sent to the Platform.
Its toString() hides most of the card number, the owner, and the CVV, so that logging it doesn't leak the card.
Listener methods
Exactly one of these methods is called for each verification, on the main thread, after the user leaves our screens.
Verification finished
override fun onVerificationFinished(outcome: SessionOutcome.Verification) {
when (outcome.state) {
VerificationState.Accept -> { ... }
VerificationState.Reject -> { ... }
VerificationState.Review -> { ... }
}
val transactionId = outcome.transactionId
}
Called when the verification reached a verdict, and the user closed the result screen.
SessionOutcome.Verification contains:
state:Accept,Reject, orReviewtransactionId: the unique identifier of the transaction
Verification canceled
override fun onVerificationCanceled(outcome: SessionOutcome.Canceled) {
val transactionId = outcome.transactionId
}
Called when the user left the verification before it finished.
SessionOutcome.Canceled contains:
reason:UserCanceledtransactionId: the unique identifier of the transaction
Verification failed
override fun onVerificationFailed(transactionId: String?, error: EngineError) {
when (error) {
EngineError.NoNetwork -> { ... }
EngineError.VerificationUnavailable -> { ... }
else -> { ... }
}
}
Called when the verification ended with an error that the user can't retry, and they closed the error screen.
transactionId: the transaction ID, ornullif the verification couldn't start at allerror: anEngineErrorthat says why the verification failed, for exampleNoNetwork,Timeout,VerificationUnavailable,RetryLimitExceeded,MissingScannerSdk,UnsupportedWorkflowVersion, orInternal