This repository contains multiple samples that demonstrate how to use the Dynamsoft Barcode Reader React-Native Edition.
- Guide for Scanning Barcodes with Ready-to-use Component
- Guide for Scanning Barcodes with Foundational APIs
There are two ways to use the Dynamsoft Barcode Reader React-Native SDK:
| Sample Name | Description |
|---|---|
| ScanBarcodes_ReadyToUseComponent | Demonstrates the quickest way to scan barcodes from live camera preview using the Ready-to-Use Barcode Scanner component, with minimal configuration required. |
| ScanBarcodes_FoundationalAPI | Demonstrates how to scan barcodes from live camera preview using the Foundational API, providing full control over camera, processing pipeline, and barcode results. |
| ScanBarcodes_Expo | Demonstrates barcode scanning using the Foundational API in an Expo (Bare) project, showing how to integrate Dynamsoft Barcode Reader into an Expo-based workflow. |
| ScanDriversLicense | Demonstrates how to recognize and extract information from drivers’ licenses in real-time video streaming. |
- Enter a sample folder that you want to try
cd ScanBarcodes_FoundationalAPIor
cd ScanBarcodes_ReadyToUseComponentor
cd ScanDriversLicense- Install node modules
Run the following command:
yarn installor
npm install- Prepare iOS
You must install the necessary native frameworks from CocoaPods to run the application. In order to do this, the pod install command needs to be run as such:
cd ios
pod installOpen the workspace file *.xcworkspace (not .xcodeproj) from the ios directory in Xcode. Adjust Provisioning and Signing settings.
- Build and Run
- Android
Go to your project folder and run the following command:
# using npm
npm run android
# OR using Yarn
yarn android- iOS
In the terminal, go to the project folder in your project:
# using npm
npm run ios
# OR using Yarn
yarn iosIf everything is set up correctly, you should see your new app running on your device. This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
Note
If you want to run Android via Windows, You may encounter some build errors due to the Windows Maximum Path Length Limitation.
Therefore, we recommend that you move the project to a directory with a shorter path.
Note
- The application needs to run on a physical device rather than a simulator as it requires the use of the camera. If you try running it on a simulator, you will most likely run into a number of errors/failures.
- On iOS, in order to run the React Native app on a physical device you will need to install the
ios-deploylibrary. Afterwards, you can run the react native app from the terminal as suchnpx react-native run-ios --deviceassuming it's the only device connected to the Mac. - Alternatively on iOS, you can simply open the xcworkspace of the project found in the
iosfolder using Xcode and run the sample on your connected iOS device from there. The advantage that this offers is that it is easier to deal with the developer signatures for deployment in there.
- Enter the Expo sample folder
cd ScanBarcodes_Expo- Install node modules
yarn installor
npm install- Generate native projects
Run the following command to generate the android and ios folders:
npx expo prebuild- Prepare iOS
Install the necessary native frameworks from CocoaPods:
cd ios
pod install
cd ..- Build and Run
- Android
npx expo run:android- iOS
npx expo run:iosNote
The application needs to run on a physical device rather than a simulator as it requires the use of the camera.
How to enable new architecture in Android
How to enable new architecture in iOS
- You can request a 30-day trial license via the Request a Trial License link.