5. To get UI updates, such as status changes, button visibility and masks, for example, override the methods below:
classYourClass:DocumentOverlayView {...// MARK: - State methodspublicoverridefuncloading(status: Bool){//Indicates the "loading" status.// The 'status' variable will be 'true' according to the SDK opening, image capture, requests to the backend... }publicoverridefuncreadyToCapture(status: Bool){ // indicates that the SDK is ready to capture, after performing all validations of sensors, framing, face, etc. }
publicoverridefuncstepDoneSuccessfully(status: Bool){//Indicates that the capture step ended successfully }publicoverridefuncvalidationFailure(status: Bool, id: ValidationFailure?){ // The 'status' variable indicates whether there are any failures in the sensor checks, quality, framing, face distance, etc.
// Most validation failures generate the "error mask" status// The variable 'id' indicates what type of error occurred. See the table below }publicoverridefunccaptureMode(status: CaptureMode){// Indicates the capture mode enabled. May vary between AUTOMATIC and MANUAL }publicoverridefuncmask(status: Mask, visibility: Bool){// The variable 'visibility' indicates the visibility of the mask or feedback areaif(visibility){switch type {case .normal:// Display the normal state mask breakcase .success:// Present the mask of successbreakcase .error:// Display the error maskbreakdefault:// Display the normal state maskbreak; } } }// MARK: - Visibility methods// Only available for DocumentDetectorpublicoverridefuncpopup(visibility: Bool){// Indicates the visibility of the step initialization popup }publicoverridefuncmanualCaptureButton(visibility: Bool){// Indicates visibility of the manual capture button }// Only available for DocumentDetector and PassiveFaceLivenesspublicoverridefuncpreview(visibility: Bool){// Indicates the visibility of the Preview (post-capture) screen }publicoverridefuncstatus(message: String, visibility: Bool) {// Use to indicate the message that should be displayed according to the states of the SDK }publicoverridefunccurrentStep(name: String){// Indicates the name of the current step }// MARK: - Deprecated methods. We do not recommend using them because in future versions they will be removedpublicoverridefuncshow(loadingshow: Bool) {// Use to indicate "loading" state }publicoverridefuncshow(messagetext: String) {// Present the messages to the user }openfuncshow(stepNametext: String) {// Indicates the name of the current step }publicoverridefuncshow(masktype: Mask) {switch type {case .normal:// Display the normal state mask breakcase .success:// Present the mask of successbreakcase .error:// Display the error maskbreakdefault:// Display the normal state maskbreak; } }publicoverridefuncshow(manualCaptureButtonhidden: Bool) {// Show or disable the manual capture button }publicoverridefuncsetCurrentAction(text: String, checked: Bool){// Present the current step with the `text' attribute }publicoverridefuncsetLastAction(text: String){ // The `text` attribute returns the last step taken. It can be used to display the capture steps already performed.
}}
6. For implementation of the close button, the cancelButtonClick method must be called. This method triggers the documentDetectorControllerDidCancel delegate and cancels the capture:
8. Finally, in DocumentDetector.CafBuilder use the method, .setOverlay(overlay: DocumentOverlayView).
ValidationFailure
Each SDK contains a number of validation errors that can occur while running. These mostly generate the "error mask" state and prevent the capture from being performed:
Error
Description
SDK
SENSOR_LUMINOSITY_FAILURE
Brightness sensor. The environment is too dark
DocumentDetector, PassiveFaceLiveness
SENSOR_ORIENTATION_FAILURE
Orientation sensor. Device is not in the correct position