Skip to main content

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.

IntegrationChoose it when
Predefined UIYou want the shortest integration and Mobai-managed capture controls.
Custom UIYour 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​

OptionDefaultPurpose
autoCaptureEnabledtrueStarts capture automatically after validation and countdown.
numberOfFrameToCollect3Number of frames sampled from the video interval.
videoCaptureDuration1000Video duration in milliseconds, clamped to 1000...3000.
timeBeforeAutomaticCapture1Countdown duration in seconds.
captureConstraints.v1Selects the V1, V2, or V3 validation pipeline.
imageQualityLevel.level3Selects V3 lighting strictness. It has no effect on V1 or V2.
isDebuggingfalseEnables SDK diagnostics and diagnostic UI.
payloadOptimizationfalseEnables 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:

OptionDefaultPurpose
showProgressBarfalseDisplays capture progress.
showFaceStatusLabelfalseDisplays geometry and V3 lighting guidance.
showCountdownTimerLabelfalseDisplays the automatic-capture countdown.
presentedDismissButtonEnabledfalseDisplays the dismiss button.
shouldShowOverlayFaceViewtrueDisplays the face placement overlay.
Debug mode

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
)

Continue the integration​