Skip to main content

Quick start

This guide takes you from an installed SDK to a complete verification: the user scans both sides of an identity document, takes a selfie with passive liveness, and you receive the result.

#StepCall
1InitialiseinitAPI()
2Start a processstartScan()
3Scan the documentdetectpreviewscanDocument()
4Verify the facevalidateFace()
5Get the resultIn your backend
Before you begin
  • The SDK is installed and the camera permission is granted.
  • You have a license key for your application ID and the URL of your MobbScan environment.

1. Initialise the SDK​

Initialise once, before any other call — for example in your Application class or launcher activity — and set the URL of your MobbScan environment.

val mobbScan = MobbScanAPI.getInstance()

mobbScan.initAPI("YOUR_LICENSE_KEY", context) { licenseResult, validTo ->
if (licenseResult != MobbScanLicenseResult.LICENSE_VALID) {
// The license is invalid or expired: do not continue
}
}
mobbScan.setBaseUrl("YOUR_MOBBSCAN_URL")

To change capture behaviour (quality checks, navigation, orientation…), pass a MobbScanConfiguration as a fourth argument. See Configuration.

2. Start a verification process​

Each verification is a process identified by a scanId. Start one with the document type and the sides to scan:

mobbScan.startScan(MobbScanDocumentType.ESP, MobbScanOperationMode.SCAN_BOTH_SIDES) { result, scanId, error ->
if (result == MobbScanStartScanResult.OK) {
this.scanId = scanId // keep it: every next call needs it
}
}
Operation modeUse it for
SCAN_BOTH_SIDESID cards, residence permits and other two-sided documents
SCAN_ONLY_BACKOne-sided documents such as passports (TD3)
SCAN_ONLY_FRONTDocuments where only the front is required

This example uses a two-sided identity document. For a one-sided document or passport, see Document scan.

One process per verification

Call startScan again for every new verification. Reusing a scanId overwrites the previous evidence.

3. Scan the document​

For a two-sided document, detect each side first and let the user review its preview. The SDK closes its camera screen after detection; your app presents the returned image and lets the user accept it or repeat that side. Send both accepted images in one scanDocument call.

In online mode, the default detectDocument overload can also start MRZ processing automatically when it detects an MRZ document.

private fun captureSide(side: MobbScanDocumentSide, onAccepted: (Bitmap) -> Unit) {
mobbScan.detectDocument(
side
) { result, detectionData, error ->
if (result != MobbScanDetectionResult.OK || detectionData == null) {
handleError(error)
return@detectDocument
}

// App-defined preview UI: accept the image or retry this same side.
showPreview(detectionData.image) { accepted ->
if (accepted) onAccepted(detectionData.image)
else captureSide(side, onAccepted)
}
}
}

captureSide(MobbScanDocumentSide.FRONT) { frontImage ->
captureSide(MobbScanDocumentSide.BACK) { backImage ->
mobbScan.scanDocument(scanId, frontImage, backImage) { result, scanData, error ->
if (result == MobbScanScanResult.COMPLETED) verifyFace()
else handleError(error)
}
}
}

Implement showPreview with your app's UI. Retry by calling detectDocument for the same side again; do not call scanDocument until the user accepts every required side.

4. Verify the face​

Capture a selfie video with passive liveness and match it against the document portrait:

mobbScan.validateFace(scanId, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE, { result, faceData, error ->
// Optional: the selfie, as soon as it is captured
}, { state, validationData, error ->
if (state == MobbScanValidationState.VALID) {
// Liveness and face match passed
}
})

5. Get the result in your backend​

The callbacks are meant to drive your UI. Take the final decision in your backend, where the result cannot be tampered with: send the scanId to your server and query the process with the MobbScan Server API, or receive it through a webhook.

See Verification result for the options.

Next steps​