Face Login

Face Login

Prerequisites

Initialize IncdOnboarding SDK

Add the following line of code to your AppDelegate class:

IncdOnboardingManager.shared.initIncdOnboarding(url: url, apiKey: apiKey)

url and apiKey will be provided to you by Incode.

If you're running the app on a simulator, please set the testMode parameter to true.

1:N Face Login - Identify a user

1:N Face login is suitable if you would like to identify a user by doing a face scan.

This will do a face match comparison across your whole user database and check if the face corresponds to any of the approved users. In case system detects a couple of similar faces it will perform step-up authentication, so that user can confirm the identity by entering requested code.

To execute 1:N Face Login call startFaceLogin method:

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startFaceLogin() { result in
          guard let loginResult = result.faceLoginResult else {
            // Some error occurred
            print(result.error)
            return
          }

if loginResult.success == true {
            // Face auth successful
            let customerUUID = loginResult.customerUUID
            let token = loginResult.token
            let interviewId = loginResult.interviewId
          } else {
            if result.spoofAttempt == true {
              // Liveness failed
            } else {
              // User's face not found
            }
          }
        }

1:1 Face Login - Verify Face for a specific user

1:1 Face Login is suitable if you want to do a Face authentication for a specific user that is already pre-authorized, meaning you already have his customer UUID and want to only know if this exact person is trying to authenticate.

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startFaceLogin(customerUUID: "YOUR_CUSTOMER_ID") { result in
          guard let loginResult = result.faceLoginResult else {
            // Some error occurred
            print(result.error)
            return
          }

## Face Login result

Resulting `SelfieScanResult` object will have:

- `faceLoginResult` - `FaceLoginResult` object that contains:
  - `success` - True if face login was successful, false otherwise.
  - `customerUUID` - Customer UUID of the matched user, nil otherwise.
  - `token` - Customer token of the matched user, nil otherwise.
  - `interviewId` - Session interviewId from which the user got approved.
  - `interviewToken` - Session interviewToken which was used during user approval.
  - `transactionId` - Transaction ID of the face login attempt.
- `spoofAttempt` - Specifies if it was a spoof attempt or not
- `image` - Selfie image taken during Selfie scan step
- `error` - `SelfieScanError` that describes the error that happened during face login

## Login parametrization

By default Face Login will do a liveness check and face match on the server, and we highly suggest switching to on-device liveness check and face match in order to improve the speed of Face Login and reduce network traffic, which is particularly important for devices that can have unstable network connection.

To switch to on-device liveness check please specify `FaceAuthMode.hybrid` via `faceAuthMode` param of the `startFaceLogin` method:

```undefined
IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startFaceLogin(faceAuthMode: .hybrid) { result in
          ...
        }

To switch to both on-device liveness check and face match please specify FaceAuthMode.local via faceAuthMode param of the startFaceLogin method:

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startFaceLogin(faceAuthMode: .local) { result in
          ...
        }

NOTE: FaceAuthMode.hybrid and FaceAuthMode.local require specific Onboarding SDK frameworks with FaceAuth models included. If using cocoapods specify l variant, i.e. 5.5.0-d-l.

Other parameters:

Manipulating locally stored identities

To be able to authenticate multiple users using 1:N and FaceAuthMode.local mode you'll need to add these users to the local database. This section will describe which methods you can use to perform CRUD operations with locally stored identities.

Add Face

To add a single identity to the local database, use addFace method and provide a FaceInfo object, that contains:

let face = FaceInfo(faceTemplate: template,
                    customerUUID: uuid,
                    templateId: templateId)
IncdOnboardingManager.shared.addFace(face)

Remove Face

To remove a single identity from the local database use removeFace method and provide a customerUUID:

IncdOnboardingManager.shared.removeFace(customerUUID: customerUUID)

Get faces

To fetch all currently stored identities use getFaces method.

  var identities: [FaceInfo] = IncdOnboardingManager.shared.getFaces()

Set multiple faces

To add multiple identities at once you can use setFaces method and provide a list of FaceInfo objects, but keep in mind it will firstly wipe out all currently stored identities.

IncdOnboardingManager.shared.setFaces(faceInfoList)

Clear face database

To clear the local database use setFaces method and provide an empty FaceInfo list of objects.

IncdOnboardingManager.shared.setFaces([])