Android-SDK-Liveness Detection(Cordova version 2D)

Demo

Install CV-Demo.apk to your phone and log in with the test account.

Integrate the plugin into your project

  1. Click to download LivenessDetectionPlugin
  2. Unzip and add the LivenessDetectionPlugin plugin to your project

    ionic cordova plugin add LivenessDetectionPlugin
  3. open/.../your-project-name/platforms/android/app/build.gradleadd 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'
    }

Quick Start

  1. 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)
  2. 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');
  3. 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)
  4. Set the action execution order cordova.plugins.LivenessDetectionPlugin.setActionSequence(shuffle,actionSequence,success,error)

  5. 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.

    A success result sample

     {
        "image":"/9j/4AAQSk.....",
        "code":null,
        "isPay":true,
        "success":true,
        "errorMessage":"SUCCESS",
        "livenessId":"8ad94d7d-fbcb-40f5-9567-21cce6986f7d",
        "transactionId":"1384b4d0cbb6adae"
    }
  6. 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')
  7. 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)
  8. Set the size of the captured image

    cordova.plugins.LivenessDetectionPlugin.setResultPictureSize(600)
  9. SDK log output switch

    cordova.plugins.LivenessDetectionPlugin.setLogEnable(false)
  10. 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..

  11. 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" />
  12. Code proguard configuration

    The SDK already has code proguard, no additional configuration is required.

  13. SDK Compatibility


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