API Reference
中文

Flutter

Only supports Android and iOS

Integrated Requirement

Compliance Explanation

Please note that when integrating SDK products provided by TrustDecision in your company's APP:

1.1 According to user information protection regulations, before users start the App for the first time and begin collecting information, your company should:

  • Fully inform the user of the purpose, method, and scope of collecting, using, and sharing personal information with a third party
  • Use an interactive interface or design (such as a privacy policy pop-up window)
  • Obtain the express consent of the end user

1.2 To provide business security and risk control services, the TrustDecision SDK will collect, process, and use the following device information:

  • Identification information (IMEI/IDFA)
  • AndroidID
  • IMSI
  • MEID
  • MAC address
  • SIM card serial number
  • Device type and model
  • System type
  • Geographical location
  • Login IP address
  • Application list
  • Running processes
  • Sensor information (light, gravity, magnetic field, acceleration, gyroscope)

Privacy Policy: TrustDecision Privacy Policy

Environment

ItemsDescription
Supported System VersionsiOS 9.0+
Supporting Architecturearmv7, arm64, x86_64

Integration Steps

There are 3 steps to integrate Liveness Detection SDK:

  1. Use the Retrieve License API to get a license within the effective timeframe
  2. Integrate the SDK for both Android and iOS platforms, initializing liveness detection with the generated license and obtaining the livenessId
  3. Use the Retrieve Result API with the generated livenessId to:
    • Obtain a selfie if liveness detection is successful
    • Receive detailed results in case of failure

1) Retrieve License API

Please follow the steps in Liveness API License Retrieval

2. SDK Integration Methods

CocoaPods Installation

  1. Add pod 'TrustDecisionPro', '4.4.2.2' in the corresponding target in the Podfile
  2. For full version, add pod 'TrustDecisionLiveness', '2.4.1'
  3. For lite version, add pod 'TrustDecisionLiveness-Lite', '2.4.0'
  4. Execute pod install --repo-update in the Podfile directory
    • M1 series Mac computers: Use arch -x86_64 pod install --repo-update

SDK Structure

Pods/TrustDecisionPro directory:

  • TDMobRisk.framework (TrustDecision SDK, static library)
  • TDCorePlugin.framework (TrustDecision plugin, embedded dynamic library)

Pods/TrustDecisionLiveness directory:

  • libTDLiveness.a (Mob-Risk SDK liveness component library, static library)
  • CWResource.bundle (Mob-Risk SDK liveness component resource package)

3. Retrieve Result API

Please follow the steps in Liveness API Result Retrieval

Other

Get SDK Version

  Future getSDKVersion()

Keep Configuration

-keep class com.trustdecision.**{*;}

All Configuration

KeyDescription平台Sample
partner(required)Partner code, contact operator to obtain.Alloptions["partner"] = "your partner"
appKey(required)Application identification, please refer tohow to get appKeyAlloptions["appKey"] = "your appKey"
country(required)Data-center: cn for China fra for Europe sg for Singapore inda for Indonesia us for the USAAlloptions["country"] = "your country"
appNameApplication name, contact operator to obtainAlloptions["appName"] = "your appName"
debugAllow debugging, default false, must be closed before the application release.Alloptions["debug"] = true
timeLimitNetwork timeout configuration, in seconds, default 15sAlloptions["timeLimit"] = 5
locationwhether collecting GPS location information, default allowedAlloptions["location"] = true
collectLevelYou can set M to control the maximum length of blackBox to 2000, default around 5000Alloptions["collectLevel"] = "M"
IDFAWhether collecting IDFA information, default allowediOSoptions["IDFA"] = true
deviceNameWhether collecting device name, default allowediOSoptions["deviceName"] = true
runningTasksWhether collecting running tasks, default allowedAndroidoptions["runningTasks"] = true
sensorWhether collecting sensor information, default allowedAndroidoptions["sensor"] = true
readPhoneWhether collecting READ PHONE STATE permission-related information, default allowedAndroidoptions["readPhone"] = true
installPackageListWhether collecting application list information, default allowedAndroidoptions["installPackageList"] = true

Liveness Module

Install the Liveness Module dependency

iOS

1.Double-click to open the Runner.xcworkspace project;

2.Find the trustdevice_pro_plugin.podspec file;

3.Add the liveness module dependency in the trustdevice_pro_plugin.podspec file

s.dependency 'TrustDecisionLiveness'

4.In the folder where Runner.xcworkspace is located, execute

pod install --repo-update

Android

1.Open the android/build.gradle file

2.Add live library dependency in android/build.gradle file

dependencies {
    implementation 'com.trustdecision.android:liveness:+'
}

Initial configuration optional parameter list

Key
Definition Description Scene Sample code

language
language type Liveness detection prompt language Default: en English Options: en English zh-Hans Simplified Chinese zh-Hant Traditional Chinese es Spanish id Indonesian ar Arabic fil Filipino ko Korean pt Portuguese ru Russian th Thai tr Turkish vi Vietnamese options["language"] = "en"

playAudio
Whether to play audio The default is NO, no audio will be played When turned on, the corresponding prompt audio will be played options["playAudio"] = false

livenessDetectionThreshold
Difficulty threshold for live detection Difficulty threshold for live detection, divided into three levels: high, medium, and low The default is medium Adjust to corresponding difficulty as needed options["livenessDetectionThreshold"] = "medium"

livenessHttpTimeOut
SDK network timeout configuration (unit: seconds) Default is 15s Customers can set the network timeout according to their needs options["livenessHttpTimeOut"] = 8

showReadyPage
When starting the face, the detection preparation page will pop up Whether to display the preparation page, the default is YES, which means it will be displayed After closing, the preparation page will not be displayed, and the identification process will be shorter options["showReadyPage"] = true

faceMissingInterval
Timeout when no face is detected (unit: milliseconds) No face timeout, unit ms, default is 1000ms Set the timeout period when no face is detected as needed options["faceMissingInterval"] = 1000

prepareStageTimeout
The starting time when preparing to detect the action (unit: seconds) Preparation phase timeout, in seconds, the default is 0S, that is, it will never time out Set the preparation phase timeout as needed options["prepareStageTimeout"] = 0

actionStageTimeout
In the action phase, the maximum verification time (unit: seconds) Action phase timeout, unit second, default is 8S Set the action phase timeout as needed options["actionStageTimeout"] = 8

Popup Liveness Window

Example Code

    String license = "please use your license!!!";

    await _trustdeviceProPlugin.showLiveness(license,TDLivenessCallback(onSuccess: (String seqId,int errorCode,String errorMsg,double score,String bestImageString,String livenessId) {
          print("Liveness success!seqId: $seqId,livenessId:$livenessId,bestImageString:$bestImageString");
       }, onFailed: (String seqId,int errorCode,String errorMsg,String livenessId) {
          print("Liveness failed!, errorCode: $errorCode errorMsg: $errorMsg");
    }));

Error Code

CodeMessage
200success (live person)
20700No face detected
20702Person change detected
20703Detection timeout
20705Screen lock or background exit during detection
20710No camera permission
20711User actively cancels detection on the preparation page
20712User actively cancels detection on the detection page
20731Face not centered
20732Face not facing the screen
20749Inconsistent action, tilt head down
60001Network issue, failed to retrieve session
60002Network issue, failed to call anti-hack
11350Internal error

3. Retrieve Result API

Please follow the steps in Liveness API Result Retrieval

Import Header File

Please import the header file if you want to call SDK API.

Objective C

#import 

Swift

import TDMobRisk

Initialization

Precautions

When the installation starts for the first time, the SDK initialization is performed after the user agrees with the privacy agreement.

Avoid SDK initialization collection without the user agreeing to the privacy agreement, causing compliance risk accidents.

Interface Definition

void (*initWithOptions)(NSDictionary *options);

initWithOptions Method Required Configuration

KeyDefinitionDescriptionSceneSample Code
partnerPartner CodePartner, please contact TrustDecision to obtainAll ScenesObjective C
[options setValue:@"[Your partner]" forKey:@"partner"];

Swift
options.updateValue("[Your partner]" as NSObject, forKey: "partner") | | appKey | App Key | Appkey, please offer your App bundleId for TrustDecision to obtain | All Scenes | Objective C [options setValue:@"[Your appKey]" forKey:@"appKey"];

Swift
options.updateValue("[Your appKey]" as NSObject, forKey: "appKey") | | country | Country Code | Country/region parameters | Fill parameters according to business region | Objective C [options setValue:@"[Your country code]" forKey:@"country"];

Swift
options.updateValue("[Your country code]", forKey: "country") |