Skip to content

Commit acb3ac8

Browse files
update to v11.2.5000
1 parent 58ed87a commit acb3ac8

File tree

17 files changed

+300
-10
lines changed

17 files changed

+300
-10
lines changed

README.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ There are two ways to use the Dynamsoft Barcode Reader React-Native SDK:
1717

1818
## Samples
1919

20-
| Sample Name | Description |
21-
|------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
22-
| [ScanBarcodes_ReadyToUseComponent](ScanBarcodes_ReadyToUseComponent)| This sample illustrates the simplest way of using `Barcode Scanner API` to recognize barcodes from video streaming. |
23-
| [ScanBarcodes_FoundationalAPI](ScanBarcodes_FoundationalAPI)| This sample illustrates the simplest way of using `Foundational API` to recognize barcodes from video streaming. |
24-
| [ScanDriversLicense](ScanDriversLicense)| This sample illustrates how to scan drivers' license from video streaming. |
20+
| Sample Name | Description |
21+
|-------------|-------------|
22+
| [ScanBarcodes_ReadyToUseComponent](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. |
23+
| [ScanBarcodes_FoundationalAPI](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. |
24+
| [ScanBarcodes_Expo](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. |
25+
| [ScanDriversLicense](ScanDriversLicense) | Demonstrates how to recognize and extract information from drivers’ licenses in real-time video streaming. |
2526

2627
### How to build and run a sample
2728

29+
#### For React Native CLI Samples
30+
2831
1. Enter a sample folder that you want to try
2932

3033
```bash
@@ -107,6 +110,60 @@ This is one way to run your app — you can also run it directly from within And
107110
>- On iOS, in order to run the React Native app on a physical device you will need to install the [`ios-deploy`](https://www.npmjs.com/package/ios-deploy) library. Afterwards, you can run the react native app from the terminal as such `npx react-native run-ios --device` assuming it's the only device connected to the Mac.
108111
>- Alternatively on iOS, you can simply open the xcworkspace of the project found in the `ios` folder 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.
109112
113+
#### For Expo Sample
114+
115+
1. Enter the Expo sample folder
116+
117+
```bash
118+
cd ScanBarcodes_Expo
119+
```
120+
121+
2. Install node modules
122+
123+
```bash
124+
yarn install
125+
```
126+
127+
or
128+
129+
```bash
130+
npm install
131+
```
132+
133+
3. Generate native projects
134+
135+
Run the following command to generate the `android` and `ios` folders:
136+
137+
```bash
138+
npx expo prebuild
139+
```
140+
141+
4. Prepare iOS
142+
143+
Install the necessary native frameworks from CocoaPods:
144+
145+
```bash
146+
cd ios
147+
pod install
148+
cd ..
149+
```
150+
151+
5. Build and Run
152+
153+
- **Android**
154+
155+
```bash
156+
npx expo run:android
157+
```
158+
159+
- **iOS**
160+
161+
```bash
162+
npx expo run:ios
163+
```
164+
165+
> [!NOTE]
166+
> The application needs to run on a physical device rather than a simulator as it requires the use of the camera.
110167
111168
### How to use the new architecture of React Native (Optional)
112169

ScanBarcodes_Expo/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
# generated native folders
40+
/ios
41+
/android
42+
43+
*lock*

ScanBarcodes_Expo/App.tsx

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
8+
import {
9+
CameraEnhancer,
10+
CameraView,
11+
CaptureVisionRouter,
12+
EnumPresetTemplate,
13+
LicenseManager,
14+
} from 'dynamsoft-capture-vision-react-native';
15+
import React, {useEffect, useRef} from 'react';
16+
import {Alert, AppState, StyleSheet, View} from 'react-native';
17+
// Initialize the license.
18+
// The license string here is a trial license. Note that network connection is required for this license to work.
19+
// You can request an extension via the following link: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=react-native
20+
const License = 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9';
21+
LicenseManager.initLicense(License).catch(e => {
22+
Alert.alert('License error', e.message);
23+
});
24+
25+
function App(): React.JSX.Element {
26+
const cameraView = useRef<CameraView>(null!);
27+
const cvr = CaptureVisionRouter.getInstance();
28+
const camera = CameraEnhancer.getInstance();
29+
30+
useEffect(() => {
31+
// Request camera permission once
32+
CameraEnhancer.requestCameraPermission();
33+
34+
// Configure router, camera and view
35+
cvr.setInput(camera);
36+
camera.setCameraView(cameraView.current);
37+
38+
// Barcode result handler
39+
const receiver = cvr.addResultReceiver({
40+
onDecodedBarcodesReceived: ({items}) => {
41+
if (items?.length) {
42+
cvr.stopCapturing();
43+
Alert.alert(
44+
`Barcodes count: ${items.length}`,
45+
items.map((barcode, i) => `${i + 1}. ${barcode.formatString}: ${barcode.text}`).join('\n\n'),
46+
[
47+
{
48+
text: 'OK',
49+
onPress: () => {
50+
cvr.startCapturing(EnumPresetTemplate.PT_READ_BARCODES)
51+
.catch(e => Alert.alert('Start error', e.message));
52+
}
53+
}
54+
]
55+
);
56+
}
57+
},
58+
});
59+
60+
// Helper to start camera + scanning
61+
const startScanning = () => {
62+
console.log('Starting...');
63+
camera.open();
64+
cvr.startCapturing(EnumPresetTemplate.PT_READ_BARCODES)
65+
.catch(e => Alert.alert('Start error', e.message));
66+
};
67+
68+
// Helper to stop camera + scanning
69+
const stopScanning = () => {
70+
console.log('Stopping...');
71+
cvr.stopCapturing();
72+
camera.close();
73+
};
74+
75+
// Initial start when component mounts
76+
startScanning();
77+
78+
// Listen to AppState changes
79+
const sub = AppState.addEventListener('change', nextState => {
80+
if (nextState === 'active') {
81+
startScanning();
82+
} else if (nextState.match(/inactive|background/)) {
83+
stopScanning();
84+
}
85+
});
86+
87+
// Cleanup on unmount
88+
return () => {
89+
sub.remove();
90+
stopScanning();
91+
cvr.removeResultReceiver(receiver);
92+
camera.setCameraView(null);
93+
};
94+
}, [cvr, camera]);
95+
96+
return (
97+
<View style={StyleSheet.absoluteFill}>
98+
<CameraView style={StyleSheet.absoluteFill} ref={cameraView}/>
99+
</View>
100+
);
101+
}
102+
103+
export default App;
104+
105+

ScanBarcodes_Expo/app.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"expo": {
3+
"name": "ScanBarcodes_FoundationalAPI_Expo",
4+
"slug": "ScanBarcodes_FoundationalAPI_Expo",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"newArchEnabled": true,
10+
"splash": {
11+
"image": "./assets/splash-icon.png",
12+
"resizeMode": "contain",
13+
"backgroundColor": "#ffffff"
14+
},
15+
"ios": {
16+
"supportsTablet": true,
17+
"infoPlist": {
18+
"NSCameraUsageDescription": "This app uses the camera to scan barcodes."
19+
}
20+
},
21+
"android": {
22+
"adaptiveIcon": {
23+
"foregroundImage": "./assets/adaptive-icon.png",
24+
"backgroundColor": "#ffffff"
25+
},
26+
"edgeToEdgeEnabled": true,
27+
"predictiveBackGestureEnabled": false,
28+
"permissions": ["android.permission.CAMERA"],
29+
"package": "com.anonymous.ScanBarcodes_FoundationalAPI_Expo"
30+
},
31+
"web": {
32+
"favicon": "./assets/favicon.png"
33+
},
34+
"plugins": [
35+
[
36+
"dynamsoft-capture-vision-react-native"
37+
]
38+
]
39+
}
40+
}
17.1 KB
Loading
1.43 KB
Loading

ScanBarcodes_Expo/assets/icon.png

21.9 KB
Loading
17.1 KB
Loading

ScanBarcodes_Expo/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { registerRootComponent } from 'expo';
2+
3+
import App from './App';
4+
5+
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6+
// It also ensures that whether you load the app in Expo Go or in a native build,
7+
// the environment is set up appropriately
8+
registerRootComponent(App);

ScanBarcodes_Expo/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "scanbarcodes_foundationalapi_expo",
3+
"version": "1.0.0",
4+
"main": "index.ts",
5+
"scripts": {
6+
"start": "expo start",
7+
"android": "expo run:android",
8+
"ios": "expo run:ios",
9+
"web": "expo start --web"
10+
},
11+
"dependencies": {
12+
"dynamsoft-barcode-reader-bundle-react-native": "^11.2.5000",
13+
"dynamsoft-capture-vision-react-native": "^3.2.5001",
14+
"expo": "~54.0.30",
15+
"expo-status-bar": "~3.0.9",
16+
"react": "19.1.0",
17+
"react-native": "0.81.5"
18+
},
19+
"devDependencies": {
20+
"@types/react": "~19.1.0",
21+
"typescript": "~5.9.2"
22+
},
23+
"private": true
24+
}

0 commit comments

Comments
 (0)