Predefined capture UI
MBCaptureSessionViewController provides the camera preview, face overlay, countdown, progress, live feedback, and capture lifecycle. Use it unless your application needs complete control over the screen layout.
| Integration | Choose it when |
|---|---|
| Predefined UI | You want the shortest integration and Mobai-managed capture controls. |
| Custom UI | Your application must own the view hierarchy and visual design. |
Configure a production session
let options = MBCaptureSessionOptions(
autoCaptureEnabled: true,
numberOfFrameToCollect: 3,
videoCaptureDuration: 2_000,
timeBeforeAutomaticCapture: 1,
captureConstraints: .v3,
imageQualityLevel: .level2
)
let style = MBUIOptions(
showProgressBar: true,
showFaceStatusLabel: true,
showCountdownTimerLabel: true,
presentedDismissButtonEnabled: true,
shouldShowOverlayFaceView: true
)
let captureController = MBCaptureSessionViewController(
with: options,
style: style,
sessionId: sessionId
)
captureController.delegate = self
present(captureController, animated: true)
sessionId is optional. Supply it when your backend flow needs authenticated frame and video session metadata.
Common capture options
| Option | Default | Purpose |
|---|---|---|
autoCaptureEnabled | true | Starts capture automatically after validation and countdown. |
numberOfFrameToCollect | 3 | Number of frames sampled from the video interval. |
videoCaptureDuration | 1000 | Video duration in milliseconds, clamped to 1000...3000. |
timeBeforeAutomaticCapture | 1 | Countdown duration in seconds. |
captureConstraints | .v1 | Selects the V1, V2, or V3 validation pipeline. |
imageQualityLevel | .level3 | Selects V3 lighting strictness. It has no effect on V1 or V2. |
isDebugging | false | Enables SDK diagnostics and diagnostic UI. |
payloadOptimization | false | Enables biometric payload-size optimization. |
For a new integration, start with .v3 and .level2, then adjust the quality level after testing on your supported devices and environments.
Configure visible UI components
The optional components default to hidden. Configure them independently of debug mode:
| Option | Default | Purpose |
|---|---|---|
showProgressBar | false | Displays capture progress. |
showFaceStatusLabel | false | Displays geometry and V3 lighting guidance. |
showCountdownTimerLabel | false | Displays the automatic-capture countdown. |
presentedDismissButtonEnabled | false | Displays the dismiss button. |
shouldShowOverlayFaceView | true | Displays the face placement overlay. |
Do not enable isDebugging just to show progress or user guidance. Enable the corresponding MBUIOptions properties so those components remain available in production builds.
Receive capture events
extension IdentityViewController: MBCaptureSessionVCDelegate {
func onSuccess(result: MBCaptureSessionResult) {
upload(result)
}
func onFailure(error: MBCaptureSessionError) {
showRetry(for: error)
}
func onStateChanged(stateEnum: MBCaptureState) {
// .onInitializing, .validating, .countdown, .capturing,
// .onProcessing, and .onCaptureFinished.
}
func onPresentedDismissTapped() {
dismiss(animated: true)
}
}
The predefined UI handles frame-by-frame feedback itself. The delegate reports completion, failure, state changes, and dismissal.
Update an existing controller
If your flow lets the user change settings before another capture, update the existing controller:
captureController.onUpdate(
with: updatedOptions,
style: updatedStyle,
sessionId: updatedSessionId
)