Skip to main content

Quick start

This guide takes you from an installed plugin to a complete verification: the user captures both sides of an identity document, then a selfie with passive liveness, and your backend receives the result.

#StepCall
1Create the processIn your backend
2InitialiseinitSdk()setBaseURL()
3StartstartScan()
4Capture the documentdetectDocument()scanDocument()
5Verify the facevalidateFace()
Before you begin

1. Create the process​

The Capacitor plugin works with processes created by your backend, so your API credentials never reach the app. Ask Mobbeel to configure your tenant for SDK integration before you start. When your backend creates a process, include countryId and docType for the document flow. Agree the supported values with Mobbeel; for example:

{
"countryId": "ESP",
"docType": "IDCard"
}

The Server API response returns scanId and token. Pass these returned values to the app:

ValueDescription
scanIdIdentifier of the process
tokenProcess token returned by the Server API. Pass it as the onboarding token to startScan.

2. Initialise the plugin​

Initialise the plugin (see Configuration for available options), then set the URL of your MobbScan environment:

const configuration = new MobbScanConfiguration();

MobbScanAPI.initSdk(configuration, () => {
MobbScanAPI.setBaseURL('https://{SERVER-URL}', onReady, onError);
}, onError);

3. Start the process​

Start the process with the returned token and scanId your backend receives when it creates the process.

MobbScanAPI.startScan(token, scanId, () => {
// Ready: capture the front of the document
}, (error: IMobbScanError) => { /* see Error handling */ });

4. Capture the document​

Register the image callback before starting detection. Each successfully detected side arrives through setScanDocumentImageCallback. Implement showPreview(image, onDecision) in your app; call onDecision(true) when the user accepts the image and onDecision(false) to retry if it is blurry, out of focus or unclear.

let front: string, back: string;

function detectSide(side: EDocumentSide) {
MobbScanAPI.detectDocument({ value: side }, onSuccess, onError);
}

MobbScanAPI.setScanDocumentImageCallback((result: IDocumentDetectionResult) => {
if (result.detectionResult !== 'OK') return; // 'PROCESS_CANCELLED' if the user left

showPreview(result.image, (accepted: boolean) => {
if (!accepted) {
detectSide(result.documentSide); // Retry this side
return;
}
handleAcceptedImage(result.documentSide, result.image);
});
});

After the user accepts the front preview, save that image and detect the back. After the user accepts the back preview, submit both images with scanDocument.

function handleAcceptedImage(side: EDocumentSide, image: string) {
if (side === EDocumentSide.Front) {
front = image;
detectSide(EDocumentSide.Back);
return;
}

back = image;
MobbScanAPI.scanDocument(scanId, front, back, onSuccess, onError);
}

Register the data callback before starting capture. It receives the extracted fields and validations after scanDocument completes:

MobbScanAPI.setScanDocumentDataCallback((result: IDocumentResponseData) => {
// result.resultData: extracted fields and validations
});

Start the sequence by detecting only the front side. The image callback then handles the preview, any retry, back-side detection and scan in order:

detectSide(EDocumentSide.Front);

This example covers a two-sided document. For one-sided documents, such as passports, use the same preview-and-accept flow for the required side before calling scanDocument.

5. Verify the face​

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

MobbScanAPI.validateFace(scanId, { value: EFaceValidationMode.LivenessVideoPassive },
(result: IFaceValidationResult) => {
// result.resultData: liveness and face matching result
},
(error: IMobbScanError) => { /* see Error handling */ });

6. Get the result​

Take the final decision in your backend: query the process with Get process information or receive it through a webhook.

Next steps​