iOS SDK Initial Integration Guide

Use this guide to integrate the FaceTec iOS SDK into Your App.

For integrating the FaceTec Android SDK into Your App, see the Android SDK Initial Integration Guide.

For integrating the FaceTec Browser SDK into Your App, see the Browser SDK Initial Integration Guide.

Video Guide

Important Note: If you are using an Apple Silicon Mac and FaceTec's .framework, you may experience unexpected behaviors building Your App on the Xcode Simulator. Before the introduction of the Apple Silicon Mac, the Xcode Simulator only used the x86_64 architecture. However, on the Apple Silicon Mac, the simulator uses the arm64 architecture. In the FaceTec SDK's .framework, the arm64 slice can only be built on actual devices (and not on a simulator). To resolve this behavior, you should use the .xcframework instead. It has a specific simulator framework with a stubbed out binary for x86 and arm64, which allows it to compile and build on the simulator.

Prerequisite

Install Xcode.

Create a New App in Xcode

  1. Open Xcode. Go to File → New → Project → App (iOS). Fill out the project options and choose "Interface: Storyboard" and "Language: Swift".

Add the FaceTec iOS SDK to Your App:

  1. Download and extract the iOS SDK. Drag the FaceTecSDK.xcframework folder into Your App in Xcode.
  2. In the left bar under Targets, choose "<YOUR_APPLICATION_NAME>. Then, choose "General" and scroll down to Frameworks, Libraries, and Embedded Content. Select "Embed & Sign" for the FaceTecSDK.xcframework.
  3. Open the Info.plist file and add the new entry Privacy - Camera Usage Description with type String and value 3D Liveness Detection by FaceTec.
  4. In ViewController.swift, import the FaceTec SDK:
    import FaceTecSDK
  5. On success, Your App will build with no errors.

Import the Default FaceTec Wrapper Classes & Methods:

  1. Open the FaceTec iOS Sample App and copy the following files over to Your App:
    • SessionRequestProcessor.swift
    • SampleAppNetworkingRequest.swift
    • Config.swift
  2. In ViewController.swift, update the ViewController Class to conform to the FaceTecInitializeCallback Protocol. Afterwards, add a property for the FaceTec SDK Instance:
    class SampleAppViewController: UIViewController, FaceTecInitializeCallback {
       var sdkInstance: FaceTecSDKInstance?
    }
  3. In ViewController.swift, add the following code to the viewDidLoad() function to initialize the FaceTec SDK:
    override func viewDidLoad() {
      super.viewDidLoad()
    
      FaceTec.sdk.initializeWithSessionRequest(deviceKeyIdentifier: Config.DeviceKeyIdentifier,
        sessionRequestProcessor: SessionRequestProcessor(), completion: self)
    }
  4. In ViewController.swift, add the onFaceTecSDKInitializationSuccess(sdkInstance: FaceTecSDKInstance) function to handle setup after initialization and the onFaceTecSDKInitializeError to handle Intialization Errors.
    func onFaceTecSDKInitializeSuccess(sdkInstance: FaceTecSDKInstance) {
      self.sdkInstance = sdkInstance
      
      // Handle Successful Initialization of the FaceTec SDK with Your Custom Logic.
      ...
    }
        
    func onFaceTecSDKInitializeError(error: FaceTecInitializationError) {
      // Handle the Initialization Error with Your Custom Logic.
      ...
    }
  5. In SampleAppNetworkingRequest.swift, remove all references to demonstrationExternalDatabaseRefID.
  6. In SampleAppNetworkingRequest.swift, remove the storeOfficialIDPhotoIfApplicable() Method and all references to it.
  7. Copy the UIColor Extension (i.e. extension UIColor {...} ) from the FaceTec iOS Sample App's ThemeHelpers.swift into Your App's Config.swift.
  8. In SessionRequestProcessor.swift, update onFaceTecExit() to the following:
    func onFaceTecExit(sessionResult: FaceTecSessionResult) {
      
      // Handle the FaceTec Session Result with Your Custom Logic.
    }
  9. On success, Your App will build with no errors.

Create and Link Button to Trigger Liveness Check:

  1. Go to Main.storyboard. Add a UIButton to the center of the screen and link it to the View Controller as the IBAction Method pressLivenessCheck(_ sender: UIButton).
  2. In ViewController.swift, configure the LivenessCheck Button by updating pressLivenessCheck(_ sender: UIButton) to the following:
    @IBAction func pressLivenessCheck(_ sender: UIButton) {
    
      // Create and launch the View Controller for a 3D Liveness Check.
      let faceTecVC = sdkInstance!.start3DLiveness(with: SessionRequestProcessor())
      self.present(faceTecVC, animated: true, completion: nil)
    }
  3. On success, Your App will be able to build and run!
Important Note: Your Application needs to wait for the FaceTec SDK to initialize before performing a 3D Liveness Check.