liveness-rn
v1.1.11
Published
My Liveness Library
Downloads
155
Readme
liveness-rn
Liveness - React Native
Request
- Minimum iOS Deployment Target: 13.0
- Xcode 14 or newer
- Swift 5
- Android minSdkVersion: 24
- Android compileSdkVersion: 33
- Android targetSdkVersion: 33
- React Native version < 0.73
Installation
package.json
"dependencies": {
"liveness-rn": "https://github.com/Techainer/rn-sdk.git#{tag_version}",
}or
"dependencies": {
"liveness-rn": "file://{path_to_folder_clone}/rn-sdk",
}Manually Installation
Android
- In root android's project -> add to
build.gradle
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}add to dependencies
implementation("com.facebook.react:react-android")
implementation('androidx.appcompat:appcompat:1.4.1')
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation('com.google.mlkit:face-detection:16.1.5')
implementation('com.otaliastudios:cameraview:2.7.2')
implementation('org.bouncycastle:bcpkix-jdk18on:1.73')
implementation('com.nimbusds:nimbus-jose-jwt:9.31')
implementation('commons-codec:commons-codec:1.16.0')compileOptions
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}gradle version
classpath com.android.tools.build:gradle:7.2.1
classpath org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_versionIOS
After pod installation is completeAdd permissions in Info.plist
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>Use to scan QR code and take photos of user's certificate and uses the camera to read passports</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>The application does not use this feature</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>The application does not use this feature</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>The application does not use this feature</string>
<key>NSDocumentsDirectory</key>
<string>The application does not use this feature</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>add Podfile
add library
<!-- pod 'QTSCardReader' ,:git => 'https://github.com/trungnguyen1791/QTSCardReader.git'
pod 'SVProgressHUD'
pod 'Alamofire', '5.8.1'
pod 'QTSLiveness'
pod 'FlashLiveness', :git => 'https://github.com/stevienguyen1988/FlashLivenessPod.git' use_frameworks!
***
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
endReact native
All ways to use the sdk have been detailed as examples in the sample folder
path example/src/App.jsOut when liveness success
Call back check isFlash
Khởi tạo đang là loại camera nào: data.nativeEvent?.data?.isFlash
Sdk flash
Trả về 2 ảnh:
- Ảnh ám màu liveness (base64): data.nativeEvent?.data?.livenessColorImage
- Ảnh thường (base64): data.nativeEvent?.data?.livenessOriginalImage
- color kiểu string ngẫu nhiểu trong các ký tự (r, g, b): data.nativeEvent?.data?.color
=> + Lưu ý màn livenesss style nên để widht: 100%, height: Platform.OS == 'android' ? windowWidth * 1.7 : '100%'
- Để khung hình camera vào giữa màn hình
Sdk 3D
Trả về 2 ảnh:
- Ảnh thường (base64): data.nativeEvent?.data?.livenessOriginalImage
- Ảnh ảnh nhiệt (base64): data.nativeEvent?.data?.livenessThermalImage
- Vertor là mảng float (2 giá trị vector): data.nativeEvent?.data?.livenessImage?.vector
Chỉ sử dụng cho Iphone x trở nên. Trường hợp nếu 10s sử dụng 3D không nhận được response trả về sẽ tự động chuyển sang Sdk flash
Trường chuyển đổi giữa Flash và 3D là isFlashCamera
isFlashCamera = true --> Sử dụng sdk flash isFlashCamera = false --> Sử dụng sdk 3D debugging = false --> bắt buộc, chuyển thành true nếu cần để test
onEvent={(data) => {
console.log('===sendEvent===', data.nativeEvent?.data);
if (data.nativeEvent?.data?.livenessImage != null || data.nativeEvent?.data?.livenessOriginalImage != null) {
if (isIphoneX && isFlashCamera) {
onCheckFaceId(data.nativeEvent?.data?.livenessOriginalImage, data.nativeEvent?.data?.livenessImage);
setIsFlashCamera(false)
} else {
onCheckFaceId(data.nativeEvent?.data?.livenessImage);
}
}
}}Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
