Skip to content

Non-UI mode

The capture module allows usage without being presented on screen. The capture (manual or automatic) is performed in background, while your app is free to present its own interface. To use it, initialize it the following way:

guard let vc = IDCameraController.instantiate() else { return }

vc.captureMode = .manual // or .auto_and_manual
vc.prepareForIAD() // prepare for IAD if needed

// Init non-UI mode
vc.ignoresLifecycleEvents = true
vc.startRunning() // manually start the photo capture.

To capture the image, either wait for the user to position their face correctly (in case of automatic capture), or call the method manually:

vc.takePhoto()

You can track the capture module's state and show the face detection feedback to the user by listening to the delegate methods:

func cameraControllerDidUpdateViewMode(_ controller: IDCameraControllerBase) {
    log("ViewMode updated: \(controller.currentViewMode)")
}

func cameraControllerShouldShowFaceDetectionMessage(_ controller: IDCameraControllerBase, result: FaceDetectorResult) -> Bool {
    // check result and present in your UI if needed
    log("FaceDetectorResult updated: \(result)")
    return  true
}

When you are done with the capture, you have to stop it manually:

vc.stopRunning()