react-native-qb-baidu-utils
v1.0.4
Published
## Getting started
Downloads
10
Readme
react-native-qb-baidu-utils
Getting started
$ npm install react-native-qb-baidu-utils --save
Mostly automatic installation
$ react-native link react-native-qb-baidu-utils
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-qb-baidu-utils
and addRNReactNativeBaiduLiveDetect.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNReactNativeBaiduLiveDetect.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNBaiduUtilsPackage;
to the imports at the top of the file - Add
new RNBaiduUtilsPackage()
to the list returned by thegetPackages()
method - problem add react-native.config.js
const path = require('path') module.exports = { dependencies: { 'react-native-qb-baidu-utils': { platforms: { android: null, // disable Android platform, other platforms will still autolink if provided }, // root: path.join(__dirname, 'node_modules/react-native-qb-baidu-utils'),//注意,不能用相對路徑 }, }, }
Append the following lines to
android/settings.gradle
:include ':react-native-qb-baidu-utils' project(':react-native-qb-baidu-utils').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qb-baidu-utils/android') include 'faceplatform-release' project(':faceplatform-release').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qb-baidu-utils/android/faceplatform-release') include 'ocr_ui' project(':ocr_ui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qb-baidu-utils/android/ocr_ui') include 'faceplatform-ui' project(':faceplatform-ui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qb-baidu-utils/android/faceplatform-ui')
Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-qb-baidu-utils')
如需使用前端活体头像功能
<receiver android:name="com.baidu.liantian.LiantianReceiver" android:exported="false"> <intent-filter> <action android:name="com.baidu.action.Liantian.VIEW" /> <category android:name="com.baidu.category.liantian"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <intent-filter android:priority="2147483647"> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <provider android:name="com.baidu.liantian.LiantianProvider" android:authorities="com.ali_live_demo.liantian.ac.provider" //<!--将com.ali_live_demo替换成您工程的包名--> android:exported="true" /> <service android:name="com.baidu.liantian.LiantianService" android:exported="false"> <intent-filter> <action android:name="com.baidu.action.Liantian.VIEW" /> <category android:name="com.baidu.category.liantian"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </service>
授权文件
下载license拷贝到工程的assets目录
Windows
用法
```js
import { NativeModules } from "react-native";
const FaceCheckHelper = NativeModules.RNBaiduFaceModule;
const BaiduAi = NativeModules.RNBaiduScanId;
//调起活体检测界面 返回最佳照片
FaceCheckHelper.startVerify({
}).then(req=>{
console.log("gotoFace",req)
})
//req 数据结构
// {
// result:{
// img:{
// imgBase64:"",
// filePath:""
// }
// }
// }
//扫描身份证 front true 为正面 false 反面
//使用之前需要先验证aksk
BaiduAi.authWithAKSK(
" ",
" "
);
BaiduAi.scanIdCard({
front:true
}).then(req => {
console.log("getIDcard", req);
});
//扫描银行卡
BaiduAi.scanBankCard(obj={}).then(req => {
console.log("getBankCard", req);
});
//req 数据结构
// {
// result:{
// img:{
// imgBase64:"",
// filePath:""
// },
// data:{
// result:{}
// }
// }
// }
```