react-native-qb-baidu-utils

1.0.4 • Public • Published

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

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-qb-baidu-utils and add RNReactNativeBaiduLiveDetect.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNReactNativeBaiduLiveDetect.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() 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'),//注意,不能用相對路徑
    	},
    },
    }
    
  1. 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')  
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      compile project(':react-native-qb-baidu-utils')
    
  3. 如需使用前端活体头像功能

    <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>
    
  4. 授权文件

    下载license拷贝到工程的assets目录
    

Windows

Read it! :D

用法

```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:{}
		// }
// 	}
// }
```

Readme

Keywords

Package Sidebar

Install

npm i react-native-qb-baidu-utils

Weekly Downloads

0

Version

1.0.4

License

none

Unpacked Size

128 MB

Total Files

1201

Last publish

Collaborators

  • suxianqing