iOS 3D Liveness Detection SDK (v3.4.1) User Guide

Development Preparation

  1. Contact us to register an account.

Overview

AAILivenessSDK contains four modules, the core module AAILivenessSDK.xcframework, the UI module AAILivenessUI, the resource module Resource, the network module AAINetwork.xcframework. The actual total size of the SDK is about 5.8MB(arm64, disable bitcode).

SDK requirements and limitations as below:

Migration Guides

  1. From version 3.4.0, the SDK only supports iOS 10.0 or higher, and the pod module AAILiveness has been renamed to AAILivenessUI.

  2. When migrating from older SDK(1.x.x) to version 2.0.1 or higher, you need to refer the document to reintegrate the SDK. We recommend using the CocoaPods for integration.

  3. From version 3.0.0, motion detection has been removed, so the properties and methods related to motion detection will not have any effect.

  4. When migrating from 1.2.9 to 1.3.0, you need to add the system library Accelerate.framework and replace all of the SDK files.

  5. When migrating from 1.2.8 to 1.2.9, you need to replace all of the SDK files("AAILiveness" folder, "AAILivenessSDK.xcframework" folder, "Resource" folder).

  6. When migrating from 1.2.7 (or lower) to 1.2.8 (or higher), you need to add the system library libz.tbd and replace all of the SDK files.

  7. From 1.2.3 or higher, AAILivenessViewController provides some public interfaces and properties, when upgrading to this version, you should use its public interfaces to implement your custom logic.

  8. If your SDK version is lower than 1.2.0, then after migrating to 1.2.0 or higher, you need to do:

    • Change the parameters of the onDetectionComplete method from NSDictionary to AAILivenessResult.
    • Add AAIModel.bundle resource.
    • Call the [AAILivenessSDK configModelBundlePath:] method to configure the path to the AAIModel.bundle file. You can refer to viewDidLoad method of AAILivenessViewController.m for more details.
  9. We recommend you read the change logs to see what has been updated in the new version of the SDK.

Run demo project

  1. The demo project is included in the SDK compressed package. Download the AAILivenessSDK and extract it, then navigate to the directory of LicenseMode/LivenessSDKObjCDemo or LicenseMode/LivenessSDKSwiftDemo project and install the dependencies:

  2. Open xcworkspace file in Xcode.

  3. Specify your market:

  4. Specify license content and start SDK, the license content is obtained by your server calling our openapi.

Installation

  1. Specify the SDK name and url in the Podfile:

    Note if you are using static link configuration(that is, you haven't configured use_frameworks! in your Podfile), you need update the pod 'AAILivenessUI' as follows:

  2. Install the dependencies in your project:

  3. Add camera、motion usage description in Info.plist as bellow. Ignore this step if you have added those.

    Note that the SDK needs to detect whether the phone is in an upright position, only when the phone is in an upright position will the SDK start detecting face, so you have to add NSMotionUsageDescription in your Info.plist.

  4. Refer to demo project to see how to use the SDK.

Manually

  1. Download the AAILivenessSDK and AAINetwork, then uncompress them and add AAILivenessSDK folder, AAINetwork.xcframework to your project:

  2. Choose "TARGETS -> General" add the following system libraries and frameworks in the Frameworks, Libraries, and Embedded Content section:

    • libz.tbd
    • libc++.tbd
    • libresolv.9.tbd
    • AVFoundation.framework
    • CoreMotion.framework
    • SystemConfiguration.framework
    • CoreTelephony.framework
    • Accelerate.framework
    • Metal.framework
    • MetalKit.framework
  3. Choose "TARGETS -> General -> Frameworks,Libraries,and Embedded Content", then set AAILivenessSDK.xcframework and AAINetwork.xcframework's Embed as "Embed & Sign".

  4. Add -ObjC to the other linker flag in the project configuration.

  5. Add camera and motion sensor (gyroscope) usage description in Info.plist as bellow. Ignore this step if you have added those.

    Note that the SDK needs to detect whether the phone is in an upright position, only when the phone is in an upright position will the SDK start detecting face, so you have to add NSMotionUsageDescription in your Info.plist.

Usage

  1. Import SDK and initialize with your market:

  2. Configure SDK license and show SDK page:

Error code

The errorCode values of AAILivenessFailedResult are as follows:

errorCoderaw native sdk codeDescription
PREPARE_TIMEOUTfail_reason_prepare_timeoutTimeout during the preparation stage
ACTION_TIMEOUTfail_reason_timeoutTimeout during the motion stage
MUTI_FACEfail_reason_muti_faceMultiple faces detected during the motion stage
FACE_MISSINGfail_reason_facemiss_blink_mouthFace is missing during the motion stage(blink or open mouth)
FACE_MISSINGfail_reason_facemiss_pos_yawFace is missing during the motion stage(pos yaw)
MUCH_ACTIONfail_reason_much_actionMultiple motions detected during the motion stage
USER_GIVE_UPuser_give_upThe user clicked the top left back button during the detection process
NO_RESPONSE Network request failed
DEVICE_NOT_SUPPORTdevice_not_supportThe front camera of this device cannot be opened
UNDEFINED Other undefined errors
...(Other server side error codes)  

Customizable UI

  1. UI Cutomization.

    File nameFile descriptionCustomizable description
    AAILivenessViewController.mDetection pageYou can implement custom UI and other logic by inheriting from this class. See the demo project for how to customize the UI.
    AAILivenessResultViewController.mDetection result pageAll UI elements can be customized. If necessary, you can implement the detectionSuccessBlk and detectionFailedBlk of AAILivenessViewController.h to enter your own app page instead of this result page
    AAIHUD.mActivity Indicator ViewAll UI elements can be customized. If necessary, you can set the showHUD property of AAILivenessViewController to NO, then implement the beginRequestBlk and endRequestBlk of AAILivenessViewController.h to show your own activity indicator view

    For more information on how to customize the UI, please refer to the question in the FAQ.

  2. Resources File Customization. Currently, this SDK supports English (en), Simplified Chinese (zh-Hans), Indonesian (id), Vietnamese (vi), Thai (th), Mexican (es), Bahasa Melayu (ms) and Hindi (hi). The SDK will use the corresponding resource file according to the current language of the device. If this device language is not in the above languages, the SDK will use English by default. If you want to support only a fixed language, you can set the language property of AAILivenessViewController. The resource files corresponding to these languages are in the following bundles:

    NameDescriptionCustomizable description
    AAILanguageString.bundleMuti-language bundleSee the FQA for how to customize the customize the localized string.
    AAIAudio.bundleAudio bundleUse your audio file to replace it. NOTE: the audio file name cannot be changed
    AAIImgs.xcassetsImage bundleUse your image file to replace it. NOTE: the image file name cannot be changed
    AAIModel.bundleModel bundleCannot be modified

 

FAQ

  1. If you add an All Exceptions breakpoint, the code could stop at player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];, Line 163 of file AAILivenessUtil.m. during face detection actions. The solution is to find All Exceptions breakpoint and edit the exception type from "All" to "Objective-C", as shown by figure below.

  2. The earliest supported iOS version is iOS9, and don't support bitcode.

  3. Can I customize the UI? Yes. From 1.2.3 or higher, AAILivenessViewController provides some public interfaces and properties, see demo project for how to customize UI or logic. For 1.2.2 or lower, AAILivenessViewController does not provide an extensible UI, so you need to modify the source code to meet your requirements. In addition, AAILivenessResultViewController is just a display result page. Normally, you can implement the detectionSuccessBlk and detectionFailedBlk of class AAILivenessViewController to jump to your own app page instead of the AAILivenessResultViewController page.

  4. How to customize the localized string?

    There are two ways to customize the localized string:

    • Add the AAILiveness.strings file to your main bundle(Recommanded).

      1. Open the project by Xcode, File->New->File->StringFile, named AAILiveness.strings.
      2. In Xcode, select the AAILiveness.strings file, in the panel on the right, you can see the Localization section, and check the languages you want to support.
      3. If you want to add a new language, select your PROJECT, in the Info panel, you can find the Localization section, click the +, select your target language, and in the subsequent session window, check the AAILiveness.strings file and click Next. This ensures that the language file you added can be correctly loaded by the SDK.
      4. You can find the en.lproj folder in the root directory after decompressing the downloaded tar.bz2 file, which contains the Localizable.strings file, and this file contains all the key-value of the text used by the SDK.
      5. You can add key-value of the localized text, SDK will priorly load the key-value in this file.
      6. If a key is not found in your file, then the SDK will use the default value. You just need to add the key-value that you want to modify to this file.
    • Using code to customize the localized string.

      You can create a subclass of AAILivenessViewController, then override the updateStateLabel:key: method to customize the localized string, finally present your subclass of AAILivenessViewController instead of the default AAILivenessViewController. For example, if you want to customize the translation of the localized key move_center in Thai(th.lproj), you can do it like this:

  5. If I have modified the UI part of the code, how do I upgrade to the new version of the SDK? Usually, only AAILivenessSDK.xcframework will be updated when the SDK is updated, the external open source code will not be modified. If the external open source code is modified in the new version of SDK, there will be detailed instructions in the release log, so you need to read the release log carefully to see if the external code has been modified.

  6. Error: Access for this account is denied You need to bind your app bundleId to the accessKey secretKey on our CMS website.(Personal Management -> ApplicationId Management)

Change logs and release history

See iOS liveness SDK release history