Skip to main content

Face matching and liveness

Face matching confirms that the person in front of the camera is alive and is the holder of the document. The SDK captures a short selfie video, the server checks liveness (presentation attack detection) and compares the face with the document portrait.

Before you begin
  • Complete a document scan in the same process (scanId), so the server has the document portrait to compare against.
  • To use the built-in face screen, add MobbScan_MobbFaceUX and MobbFaceUX. See Installation.

Choose a validation mode​

MobbScanFaceValidationModeWhat the user doesLiveness
LIVENESS_VIDEO_PASSIVE (recommended)Looks at the camera for a few seconds✓ passive, no gestures
DEFAULTTakes a selfie✗ face match only

Use LIVENESS_VIDEO_PASSIVE for remote identity verification. DEFAULT does not protect against photos or screens and should not be used for remote onboarding.

Verify the face​

validateFace presents the face capture screen, records the video, and returns the liveness and matching result:

let params = MobbScanFaceValidationParams()
params.faceValidationMode = .LIVENESS_VIDEO_PASSIVE

MobbScanAPI.getInstance().validateFace(forScanId: scanId, params: params, withFaceAcquisitorResult: { result, faceData, error in
// Optional: the selfie, as soon as it is captured
}, withCheckResult: { state, validationData, error in
// Liveness and face matching result
})

The face acquisition block is optional; pass it only if you need the selfie in the app.

Read the result​

MobbScanValidationStateMeaning
VALIDThe validation passed
NOT_VALIDThe validation was performed and did not pass
NOT_CHECKEDThe validation could not be performed or does not apply

In liveness modes, cast MobbScanValidationResultData to MSIdentityVerificationValidationResultData for the detailed result:

PropertyDescription
livenessValidationMobbScanValidationState of the liveness check
faceMatchingValidationMobbScanValidationState of the face comparison
identityVerificationValidationOverall MobbScanValidationState
livenessScoreLiveness confidence
faceMatchingScoreSimilarity between the selfie and the document portrait
identityVerificationScoreOverall confidence
faceSelfieFace extracted from the selfie video
faceDocumentPortrait extracted from the document

In DEFAULT mode, cast it to FaceRecognitionValidationResultData to read currentFace (the selfie) and score.

The validation thresholds are configured on the server. Use the states, not the raw scores, to drive your UI, and take the final decision in your backend.

Other options​

Use your own selfie​

If you capture the selfie yourself, send it for matching. No liveness check is performed in this case.

MobbScanAPI.getInstance().validateFace(forScanId: scanId, withFace: selfieImage) { state, validationData, error in
// Face matching result
}

Capture only​

detectFace runs the face capture without validating it. In liveness modes, it also returns the recorded video (faceVideo).

let params = MobbScanFaceValidationParams()
params.faceValidationMode = .LIVENESS_VIDEO_PASSIVE

MobbScanAPI.getInstance().detectFace(params) { result, faceData, error in
// result == .FACE_ACQUIRED: faceData.faces and faceData.faceVideo
}

Compare with another portrait​

MobbScanAPI.getInstance().validateFace(forScanId: scanId, withDocumentImage: chipPortrait, params: params,
withFaceAcquisitorResult: nil,
withCheckResult: { state, validationData, error in /* result */ })