Active Liveness iOS SDK (Basic Implementation)

About Active Liveness iOS SDK

IdentifAI Active Liveness iOS SDK is an extension of IdentifAI Cloud Face Liveness to give suggestions to check if the person is ‘Live’ by asking them to do some expressions then AI predicts the liveness. This prevents artificial input (e.g. image from the library, print attack) to enter your identity verification System.
The following content assumes you're using our SDK 1.2.6 and below versions. If you are currently using 1.2.6 or below, please refer to this migration to update to the latest version 2.0.0 for more information.

Getting Started

Requirement

  • Recommended Xcode version: 13
  • Minimal iOS version: 11
  • Docs use Swift
  • IDE in this document uses Xcode

Prerequisite

Please install Cocoapods version 1.0.0. You can find the installation guide here.

Get Access Key

Before starting integration, you will need API access_key and secret_key . You can get the access_key and secret_key on your application dashboard, please visit dashboard.identifai.id/application.

Initialize Cocoapods

  1. 1.
    Include the following Nodeflux pod in your podfile pod 'LivenessSDK', git:'https://github.com/nodefluxio/ios-sdk-face-liveness.git', tag: '2.1.1'. Alternatively, you can download the latest iOS Liveness framework and add xcframework file to your current project.
  2. 2.
    Open the terminal and go to the root of your project. Input command “pod install”, SDK and its dependency should automatically fetch itself.
  3. 3.
    Next open your swift file, where you want to import Nodeflux SDK by add Import LivenessSDK
  4. 4.
    Now your SDK is ready.

Integration Using Basic Implementation

On the basic implementation, you only need to provide your access key and secret key on the application for quick integration. However, this implementation is not recommended for production purposes. To check the implementation please refer to our GitHub https://github.com/nodefluxio/ios-sdk-face-liveness.
Example implementation:
import UIKit
import AVFoundation
import LivenessSDK
class ViewController: UIViewController {
@IBOutlet var ScoreLabel: UILabel!
private var accessKey: String = "Your Access Key"
private var secretKey: String = "Your Secret Key"
private var submissionToken: String?
// Create variable of Liveness SDK
var SDKController: SDKViewController?
// You can start Nodeflux Liveness SDK via button or any other screen lifecycle
@IBAction func startSDK(_ sender: UIButton) {
SDKController = SDKViewController(accessKey: self.accessKey, secretKey: self.secretKey, submissionToken: self.submissionToken ?? "")
SDKController?.delegate = self
self.present(SDKController!, animated: true)
}
}
extension ViewController: SDKViewControllerDelegate {
func onSuccess(score: Float, isLive: Bool, images: [String]) {
// You can handle success process from this delegate function
}
func onSuccessWithSubmissionToken(jobID: String, images: [String]) {
// You can neglect this delegate function
}
func onError(message: String, errors: [String : Any]) {
// You can handle error process from this delegate function
}
}
Variable description:
  • accessKey : a user key for authentication purposes.
  • secretKey : the private key for authentication purposes.
  • isLive : boolean type to return face liveness check is true or false.
  • Images : return an image with base64 type.
  • score : return liveness score on a double type from 0.0 to 1.0

Configurable Parameter

On Nodeflux Liveneness SDK, you can configure some parameter setting such as liveness threshold, adjust image quality threshold, image quality behavior, and activate only passive liveness behavior. If you want to change any SDK default settings, specify those settings with NodefluxLivenessSDKOptions Object, you can change the following setting:
Setting
Description
Data Type
Default Value
setAccessKey
optional (required if you using basic implementation)
String
nil
setSecretKey
optional (required if you using basic implementation)
String
nil
setSubmissionToken
optional (required if you using submission_token implementation)
String
nil
setThreshold
optional (number of threshold for acceptence score)
Double
0.7
setActiveLivenessFlag
optional (boolean flag to activate or deactivate active liveness)
Boolean
true
setImageQualityFilter
optional (boolean flag to activate or deactivate iqa )
Boolean
nil
setImageQualityAssessment
optional (custom value for iqa parameter)
String
nil
setTimeoutThreshold
optional (millisecond value of active liveness duration)
Int
30000ms
setGestureToleranceThreshold
optional (millisecond value of each gesture tollerance)
Int
10000ms
setSessionID
optional (this session ID is used for tracking capability and reconciliation)
String (Max 128 digits)
nil