react-native 掃一掃功能(二維碼掃描)功能開發


1.安裝插件

yarn add react-native-smart-barcode

2.關聯

react-native link react-native-smart-barcode

3.修改 android/settings.gradle

rootProject.name = 'Example'
include ':react-native-smart-barcode'
project(':react-native-smart-barcode').projectDir = new File(rootProject.projectDir, '../node_modules/react- 
native-smart-barcode/android')

include ':app'

4.修改 android/app/build.gradle

dependencies {
  compile project(':react-native-smart-barcode')
  ...
}

5.修改 android/app/src/main/AndroidManifest.xml

<!-- smart-barcode所需權限 開始-->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<!-- smart-barcode所需權限 結束-->

6.修改 android/app/src/main/java/com/example/MainApplication.java

import com.reactnativecomponent.barcode.RCTCapturePackage;

new RCTCapturePackage(),

.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM