react-native-dbr
This is a sample that shows how to implement barcode scanning in React Native using Dynamsoft Barcode Reader SDK.
Dependencies
How to Run the Example
iOS
Run npm install or yarn (npm install -g yarn)
from the Example directory first, then pod install
in the react-native-dbr/Libraries.
And make sure Your Project Target -> Build Settings -> Search Paths -> Frameworks Search Paths
:
Then react-native run-ios
.
Android
Screenshots
How to Use the Barcode Scanning Module
In Android
-
Create a new React Native project.
-
Add the local module to dependencies in
package.json
. -
Link dependencies.
-
Use flatDir to define library path in
android/build.gradle
.flatDir { dirs project(':react-native-dbr').file('lib') }
-
Use the module in
App.js
.
In iOS
-
Create a new React Native project.
-
Add the local module to dependencies in
NewProject/package.json
. -
Remove
node_moudules
and install. -
Add
BarcodeReaderManager.xcodeproj
to your project libraries. And make surePods/Target Support Files/Pods-BarcodeReaderManager.debug.xcconfig
:
FRAMEWORK_SEARCH_PATHS = "${PODS_ROOT}/DynamsoftBarcodeReader"
HEADER_SEARCH_PATHS = "${PODS_ROOT}/DynamsoftBarcodeReader/DynamsoftBarcodeReader.framework/Headers"
LIBRARY_SEARCH_PATHS = "${PODS_ROOT}/DynamsoftBarcodeReader"
OTHER_LDFLAGS = -framework "DynamsoftBarcodeReader"
- In your NewProject:
Project -> Build Settings -> FRAMEWORK_SEARCH_PATHS = `$(PROJECT_DIR)/../Libraries`
HEADER_SEARCH_PATHS = `$(PROJECT_DIR)/../Libraries`
-
Modify the module in
App.js
(different from android). -
To achieve navigation from react-native to viewController, in
AppDelegate.h
andAppDelegate.m
, add the following code: