Megration Guides(Reacet Native)
From 4.0.0, we've introduced significant API improvements and feature enhancements. To make upgrading easier, here’s what you need to know:
Dependency Method
Previously, the module was used by importing the source code. Now, it has been changed to depend on the NPM repository, and we unified the RN plugin's public API. Please re-integrate by referring to the latest documentation. Available configuration options are now defined by the newest plugin version. If you need additional settings, contact us.
Add the dependency in package.json:
"dependencies": {
"liveness-plugin": "^4.0.1"
}
For Android, you need to do:
- Add the Maven repository to the
settings.gradle
orbuild.gradle
file in the Android directory of your React Native project:rootProject.allprojects { repositories { google() jcenter() repositories { maven { url 'https://public-n3.advai.net/repository/maven-releases/' } } } }
- You need to remove the liveness-plugin module, and no longer manually add the package in the Application:
add(LivenessReactPackage())
API Changes
For Android side, from 4.0.0 some APIs in the table below are now removed. You’ll need to update your code accordingly.
Method/Property | Alternative | Notes |
---|---|---|
setActionSequence | No need to call. | |
setDetectionLevel | No need to call. | |
setVideoConfig | No need to call. | |
setAuditConfig | No need to call. | |
setDetectOcclusion | No need to call. | |
set3DLivenessTimeoutMills | No need to call. | |
setActionTimeoutMills | No need to call. | |
setResultPictureSize | No need to call. | |
bindUser | No need to call. | |
setSignatureId | No need to call. |
For iOS side,since we've unified the RN plugin's public API, all pre-4.0.0 RN public APIs are no longer supported. Please follow the latest plugin's public API as your reference.
The recommended alternative for the deprecated API is as follows:
const livenessParams: LivenessParams = {
cameraType: 'FRONT',
detectOcclusion: false, // occlusion
auditImageConfig: {
enableCollectSwitch: true, // Whether to enable the audit image collection switch
imageWidth: 400, // Image width
imageQuality: 30, // Image quality
relativeSecondsCaptureAfterCameraLaunched: 3.0, // Capture image at a relative number of seconds after the camera is launched
},
livenessType: 'test_more', // Liveness detection type
signatureId: '', // Signature ID, if available
distantNearTimeout: 50000, // Timeout for distant-near detection in milliseconds
silentTimeout: 50000, // Timeout for silent detection in milliseconds
actionTimeout: 10000, // Timeout for actions in milliseconds
prepareMillSeconds: 0, // Preparation time in milliseconds
resultPictureSize: 600, // Result picture size
maxRecordVideoSeconds: 600, // Maximum video recording time in seconds
userId: '', // User ID, in JSON string format
maskColor: '#000000', // Mask color
ovalColor: '#000000', // Oval color
ovalNormalColor: '#000000', // Normal oval color
};
startLivenessDetection(livenessParams, result => {
console.log('Liveness detection result received:', result);
setStatusMessage('Liveness detection finished.');
setLivenessResult(result);
setIsLoading(false);
});
For detailed integration instructions, please refer to the integration documentation.
Updated 5 days ago