Skip to main content

Quick Setup

After following the install instructions you are ready to launch the SDK. The quick setup will go over how to launch the SDK using SwiftUI, but the UIKit implementation is identical, other than that it uses FaceCameraSDK.controller(delegate:) instead of FaceCameraSDK.controllerSwiftUIWrapper(delegate:). Both entry points are @MainActor, so call them from the main actor.

Launching in SwiftUI

  1. Instantiate the controller and present it in SwiftUI:
extension HomeView {
var body: some View {
VStack(spacing: 20) {
}
.fullScreenCover(isPresented: $viewModel.showCamera) {
FaceCameraSDK.controllerSwiftUIWrapper(delegate: viewModel.delegateHandler)
}
}
}

To handle receiving the result and other events, you need to implement the following delegate methods:

class FaceCameraDelegateHandler: NSObject, FaceCameraListenable {
weak var parent: HomeViewModel?

init(parent: HomeViewModel) {
self.parent = parent
}

func didEncounterError(_ error: FaceCameraError) {
}

func didCapture(_ result: FaceCameraResult) {
}

func didCancel() {
}

func didTapBack() {
}
}

Note: Error Codes can be found here

Injection Attack Detection (IAD)

Both entry points also take an iadEnabled parameter, which defaults to true:

FaceCameraSDK.controllerSwiftUIWrapper(delegate: viewModel.delegateHandler, iadEnabled: true)

FaceCameraSDK.controller(delegate: viewModel.delegateHandler, iadEnabled: true)

Leave it at the default unless you have a specific reason not to. With iadEnabled: false the SDK skips building the IAD bundle, and the encryptedBlob on FaceCameraResult comes back empty — since that blob is what you send to the server, no IAD check is possible for that capture. See About for what IAD covers.

Start the Camera

First check camera permissions and if not present obtain the camera permission. The camera will error if the camera permission is not present.

After ensuring that the camera permissions are present, present the viewcontroller, it will automatically start the capture process when loaded.