Customize Unattended Process
Overview
The unattended video process can be customized as well as the other process. This process customization also comes in two flavors: simple and full.
Customize Default Process
This is the simplest way of customize the unattended process. Just add a file named ms_theme.plist
into your application project and override
some or all of the followings properties:
Property | Type | Default Value | Description |
---|---|---|---|
MSUThemeKeyLoadingBackgroundColor | String | #FFFFFF | Background color of the loading view (RGB) |
MSUThemeKeyLoadingSpinnerColor | String | #FE3D6A | Color of the spinner image displayed while loading (RGB) |
MSUThemeKeyLoadingTextColor | String | #000000 | Message font color of loading view |
MSUThemeKeyCancelButtonColor | String | #FFFF00 | Cancel button color (RGB) |
MSUThemeKeyDocumentOverlayColor | String | #000000BF | (Document Step) Color of the overlay view (RGB/RGBA) |
MSUThemeKeyDocumentFrameLineWidth | Number | 2 | (Document Step) Line width of the detection box |
MSUThemeKeyDocumentFrameDefaultColor | String | #FFFFFF | (Document Step) Default color of the detection box line (RGB) |
MSUThemeKeyDocumentFrameDetectingStateColor | String | #A5DB30 | (Document Step) Color of the detection box line displayed when documents are being detected |
MSUThemeKeyDocumentCountdownTextSize | Number | 40 | (Document Step) Countdown font size |
MSUThemeKeyDocumentCountdownTextColor | String | #FFFFFF | (Document Step) Countdown font text color |
MSUThemeKeyDocumentTextColor | String | #FFFFFF | (Document Step) Feedback messages font color (RGB) |
MSUThemeKeyDocumentTextSize | Number | 16 | (Document Step) Feedback messages font size |
MSUThemeKeyFaceOverlayColor | String | #000000 | (Face Step) Color of the overlay view (RGB) |
MSUThemeKeyFaceOverlayAlpha | Number | 0.75 | (Face Step) Transparency of the overlay view |
MSUThemeKeyFaceAnimationLineColor | String | #FFFFFF | (Face Step) Color of the shape strokes of the animations (RGB) |
MSUThemeKeyFaceTextColor | String | #FFFFFF | (Face Step) Feedback message font color |
MSUThemeKeyFaceTextBackgroundColor | String | #00000000 | (Face Step) Feedback message font background color |
MSUThemeKeyFaceTextShadowColor | String | #00000077 | (Face Step) Feedback message font shadow color |
MSUThemeKeyFaceTextShadowOffset | Array | [2,2] | (Face Step) Feedback message font shadow offset |
MSUThemeKeyOTPBackgroundColor | String | #0000008C | (OTP Step) Color of the overlay view (RGB/RGBA) |
MSUThemeKeyOTPTextColor | String | #FFFFFF | (OTP Step) Feedback message font color |
MSUThemeKeyOTPCardTextColor | String | #4287F5 | (OTP Step) Card text color |
MSUThemeKeyOTPCardBackgroundColor | String | #FFFFFF | (OTP Step) Card background color |
MSUThemeKeyOTPButtonTextColor | String | #FFFFFF | (OTP Step) Done button text color |
MSUThemeKeyOTPButtonBackgroundColor | String | #4287F5 | (OTP Step) Done button background color |
MSUThemeKeyStatusBarAuto | Boolean | true | Whether or not the status bar style should be updated based on background color (*) |
MSUThemeKeyStatusBarStyle | String | light | Status bar style (light/default). Only relevant if MSUThemeStatusBarAuto is false |
(*) Dark backgrounds will display light style. Light backgrounds will display default style.
Full Customization
If you need a more extensive customization for your unattended process, you can define your own interfaces. You can also indicate an UIView to the MobbScan API so it can draw the camera flow.
This way, the camera flow that is used for document and face detection will be shown in your desired view, and you can paint your own interfaces over it, show messages, and handle the events that suit your needs.
Follow the next steps in order to have a nice, functional ViewController with an unattended process.
Note: This functionality is allowed by MobbScan from its version 2.18.0
Start unattended process
First of all you need to start the unattended process. By doing this, MobbScan API connects with the server and gets itself configured so every operation (document or face detection) that you perform will be recorded on a video.
This is the method you need to invoke for this purpose:
MobbScanAPI.getInstance().startUnattendedVideoDetecting(for: view, withScanId: scanId, recordingVideoStartedListener: {
(result, error) in
// Start result block code
})
[[MobbScanAPI getInstance] startUnattendedVideoDetectingForView:view withScanId:scanId recordingVideoStartedListener:^(VideoUnattendedResult result, NSError *_Nullable error) {
// Start result block code
}];
The parameters of this method are:
view
This is anUIView
object which will show the camera during unattended process. Over this view you will paint the detection interfaces you are going to use.scanId
This is the scanId you got onstartScan
process.recordingVideoStartedListener
This block will be invoked once the API connects with the server side and the video begins to record. At this point, the camera will be shown on the view you indicated on the first parameter. The listener provides two objects:result
can beOK
orERROR
. It indicates if the start process was successful or if there was a problem during the start process.error
will benil
if result isOK
and will provide some information if result wasERROR
.
By doing this, the camera will be shown in the view you provide. Over this view, you can push the elements you desire, either before the process starts and later when you call the MobbScan detection methods.
Switch camera
The camera preview will be shown in the view you provided. By default, the back camera is initialized. However, you can switch between both cameras so you can perform some operations like facial detection in the first place.
MobbScanAPI.getInstance().switchUnattendedVideoCamera()
[[MobbScanAPI getInstance] switchUnattendedVideoCamera];
Document and face detection
Once you have the API configured for the unattended process, you can perform document and face detection using your own interfaces.
Take a look at the document customization section and the face detection section to check how to build your interface and paint the detection feedback.
Note: The detection will be done over the camera flow that is being shown in the view you provided, so you must paint your interfaces over this view. This means that you cannot change the ViewController where you are running the process. You must keep the same ViewController during the whole unattended process.
Note: When you customize the MobbScan interfaces, you will be asked to set an
UIView
as camera container in the MobbScandetectionTracks
. You must set the view you provided in the methodstartUnattendedVideoDetectingForView
.
Stop unattended process
Once the user has finished the detection process (document and/or face detection), you must stop the unattended process so the camera stops recording and the server side stores the video. This is also useful to check from the application side that everything was fine in the server side and that the video was successfully stored.
MobbScanAPI.getInstance().stopUnattendedVideoDetecting(_: {
(result, error) in
// Stop result block code
})
[[MobbScanAPI getInstance] stopUnattendedVideoDetecting:^(VideoUnattendedResult result, NSError *_Nullable error) {
// Stop result block code
}];
This method only has recordingVideoStopListener
as a parameter. This block will be invoked once the process is disconnected from the server side, and the video stops recording.
result
can beOK
orERROR
. It indicates if the start process was successful or if there was a problem during the start process.error
will benil
if result isOK
and will provide some information if result wasERROR
.
Cancel Unattended Process
Chances are that you might need to cancel some processes for reasons as the user cancels the process or the document scanning process fails...
This can be achieved by invoking cancelUnattendedVideo
method. You will need to provide at least the cancellation reason and whether or not the scanning evidences will be removed from the server.
Optionally you can pass in a listener to be notified when the cancellation process ends.
MobbScanAPI.getInstance().cancelUnattendedVideo(true, reason: .USER_CANCELLED, finishListener: nil)
[self.mobbScanAPI cancelUnattendedVideo:YES
reason:MSUnattendedVideoCancelReason_USER_CANCELLED]
finishListener:nil];
Possible reasons are:
USER_CANCELLED_ERROR
TIMEOUT_ERROR
DOCUMENT_NOT_CLASSIFIED_ERROR
DOCUMENT_NOT_VALID_ERROR
IDENTITY_VERIFICATION_NOT_VALID
CONNECTION_ERROR