Install CV-Demo.apk to your phone and log in with the test account.
Unzip and add the LivenessDetectionPlugin
plugin to your project
ionic cordova plugin add LivenessDetectionPlugin
open/.../your-project-name/platforms/android/app/build.gradle
add these dependencies:
repositories {
maven {
url 'https://public-n3.advai.net/repository/maven-releases/'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: '*.aar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.android.support:support-annotations:27.+"
// SUB-PROJECT DEPENDENCIES END
...
// Add the following line of dependencies
implementation 'ai.advance.mobile-sdk.android:liveness-detection-ui:2.1.6'
// Version history see:
// http://public-n3.advai.net/repository/maven-releases/ai/advance/mobile-sdk/android/liveness-detection/maven-metadata.xml
implementation 'ai.advance.mobile-sdk.android:liveness-detection:2.1.8'
}
Initialization SDK.
Available values for Market: [Indonesia, India, Philippines, Philippines2, Vietnam, Malaysia, Thailand, BPS, CentralData, Mexico, Singapore, Aksata, Pakistan, Nigeria]
The last boolean value indicates whether you are opening a Global service or not, and is set to true if it is, or false if it is not.
cordova.plugins.LivenessDetectionPlugin.initSDKByLicense('your market',false)
Set movement difficulty level(Called before the setLicenseAndCheck() method, otherwise it does not take effect)
You can specify the difficulty of the action detection according to your business requirements (EASY,NORMAL,HARD),default level is NORMAL
cordova.plugins.LivenessDetectionPlugin.setDetectionLevel('NORMAL');
Check License
The license is obtained by your server calling our openAPI, you need to check license before starting the liveness detection activity.
cordova.plugins.LivenessDetectionPlugin.setLicenseAndCheck(your license,success,error)
Set the action execution order cordova.plugins.LivenessDetectionPlugin.setActionSequence(shuffle,actionSequence,success,error)
Start the liveness detection check and obtain the check result.
Each time the liveness detection is successful, a unique livenessId and a clear photo of 300*300 pixels for this test will be returned.
You can get the image directly through the methods provided by the SDK, or you can call the openAPI from the server.
// After the liveness detection is over, we will return the detection results immediately
cordova.plugins.LivenessDetectionPlugin.startLivenessDetection(result=>{
alert(result)
})
// You can also call getResultData function at other times after liveness detection is completed to get the detection result.
cordova.plugins.LivenessDetectionPlugin.getResultData(result=>{
alert(result)
})
A success result sample
{
"image":"/9j/4AAQSk.....",
"code":null,
"isPay":true,
"success":true,
"errorMessage":"SUCCESS",
"livenessId":"8ad94d7d-fbcb-40f5-9567-21cce6986f7d",
"transactionId":"1384b4d0cbb6adae"
}
User binding (strongly recommended).
You can use this method to pass your user unique identifier to us, we will establish a mapping relationship based on the identifier。It is helpful for us to check the log when encountering problems.
cordova.plugins.LivenessDetectionPlugin.bindUser('your unique userId')
Turn on occlusion detection
If you want to enable occlusion detection, please call the following method after initializing the SDK to set it
cordova.plugins.LivenessDetectionPlugin.isDetectOcclusion(true)
Set the size of the captured image
cordova.plugins.LivenessDetectionPlugin.setResultPictureSize(600)
SDK log output switch
cordova.plugins.LivenessDetectionPlugin.setLogEnable(false)
Multilingual
Currently SDK supports six languages/voice: Chinese, English, Indonesian, Vietnamese,Hendi,Thai.Automatically switch according to the current language of the mobile phone, no code setting is required..
If the SDK does not automatically switch with the system language, please check your cellphone language settings and make sure that both [Region] and [Language] are switched to the corresponding language.
If it still have problems with multiple languages and the app only supports one language, you can filter out the unwanted languages by adding the following configuration to build.gradle
android {
defaultConfig {
...
resConfigs("in-rID") // For example, only Indonesian is supported
}
}
Runtime Permissions
This SDK requires the following permissions, which have been configured in the aar manifest file and the SDK itself is ready for dynamic application of Android 6.0+ permissions.
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
Code proguard configuration
The SDK already has code proguard, no additional configuration is required.
SDK Compatibility
armeabi-v7a
,arm64-v8a
,x86
,x86_64
,armeabi
Error Code:
code |
---|
FACE_MISSING |
ACTION_TIMEOUT |
MULTIPLE_FACE |
MUCH_MOTION |
AUTH_BAD_NETWORK |
CHECKING_BAD_NETWORK |
DEVICE_NOT_SUPPORT |
USER_GIVE_UP |
UNDEFINED |
NO_RESPONSE |
AUTH_PARAMETER_ERROR |
AUTH_IAM_FAILED |