@@ -60,8 +60,6 @@ A lightweight, high-performance React Native library for scanning QR codes and b
6060| ** 0.79.x** | ✅ ** 1.0.x** | ** New Architecture (default)** | ** Latest - Full Support** |
6161| 0.80.x+ | 🔜 1.0.x | New Architecture | Ready when released |
6262
63- ** Latest Version** : v1.0.0 - Major stable release with enhanced CI pipeline and build reliability improvements
64-
6563### Requirements
6664
6765- ** React Native** : >=0.70.0
@@ -129,15 +127,19 @@ npx expo run:android
129127### Basic Usage
130128
131129``` typescript
132- import ImageCodeScanner from ' react-native-image-code-scanner' ;
130+ import ImageCodeScanner , { ScanResult } from ' react-native-image-code-scanner' ;
133131
134132// Scan QR code from image
135133const scanQRCode = async (imagePath : string ) => {
136134 try {
137- const results = await ImageCodeScanner .scan ({ path: imagePath });
135+ const results: ScanResult [] = await ImageCodeScanner .scan ({
136+ path: imagePath ,
137+ });
138138
139139 if (results .length > 0 ) {
140- console .log (' QR Code found:' , results [0 ]);
140+ const firstResult = results [0 ];
141+ console .log (' QR Code found:' , firstResult .content );
142+ console .log (' Format:' , firstResult .format ); // "QR_CODE"
141143 } else {
142144 console .log (' No QR code found in image' );
143145 }
@@ -152,11 +154,12 @@ const scanQRCode = async (imagePath: string) => {
152154``` typescript
153155import ImageCodeScanner , {
154156 BarcodeFormat ,
157+ ScanResult ,
155158} from ' react-native-image-code-scanner' ;
156159
157160const scanMultipleFormats = async (imagePath : string ) => {
158161 try {
159- const results = await ImageCodeScanner .scan ({
162+ const results: ScanResult [] = await ImageCodeScanner .scan ({
160163 path: imagePath ,
161164 formats: [
162165 BarcodeFormat .QR_CODE ,
@@ -166,7 +169,10 @@ const scanMultipleFormats = async (imagePath: string) => {
166169 // Automatic preprocessing is enabled by default for optimal recognition
167170 });
168171
169- console .log (' Found barcodes:' , results );
172+ results .forEach ((result , index ) => {
173+ console .log (` Barcode ${index + 1 }: ` , result .content );
174+ console .log (` Format: ` , result .format );
175+ });
170176 } catch (error ) {
171177 console .error (' Scan error:' , error );
172178 }
@@ -187,7 +193,7 @@ As soon as a barcode is detected with any technique, the result is returned imme
187193### With Image Picker
188194
189195``` typescript
190- import ImageCodeScanner from ' react-native-image-code-scanner' ;
196+ import ImageCodeScanner , { ScanResult } from ' react-native-image-code-scanner' ;
191197import { launchImageLibrary } from ' react-native-image-picker' ;
192198
193199const scanFromGallery = async () => {
@@ -199,14 +205,17 @@ const scanFromGallery = async () => {
199205 if (result .assets && result .assets [0 ]) {
200206 const imagePath = result .assets [0 ].uri ;
201207
202- const scanResults = await ImageCodeScanner .scan ({
208+ const scanResults: ScanResult [] = await ImageCodeScanner .scan ({
203209 path: imagePath ,
204210 formats: [ImageCodeScanner .BarcodeFormat .QR_CODE ],
205211 // Automatic preprocessing is enabled by default
206212 });
207213
208214 if (scanResults .length > 0 ) {
209- console .log (' Barcode data:' , scanResults );
215+ scanResults .forEach ((result ) => {
216+ console .log (' Content:' , result .content );
217+ console .log (' Format:' , result .format );
218+ });
210219 }
211220 }
212221};
@@ -215,7 +224,7 @@ const scanFromGallery = async () => {
215224### With Expo Image Picker
216225
217226``` typescript
218- import ImageCodeScanner from ' react-native-image-code-scanner' ;
227+ import ImageCodeScanner , { ScanResult } from ' react-native-image-code-scanner' ;
219228import * as ImagePicker from ' expo-image-picker' ;
220229
221230const scanFromGallery = async () => {
@@ -228,14 +237,17 @@ const scanFromGallery = async () => {
228237 if (! result .canceled && result .assets && result .assets [0 ]) {
229238 const imagePath = result .assets [0 ].uri ;
230239
231- const scanResults = await ImageCodeScanner .scan ({
240+ const scanResults: ScanResult [] = await ImageCodeScanner .scan ({
232241 path: imagePath ,
233242 formats: [ImageCodeScanner .BarcodeFormat .QR_CODE ],
234243 // Automatic preprocessing is enabled by default
235244 });
236245
237246 if (scanResults .length > 0 ) {
238- console .log (' Barcode data:' , scanResults );
247+ scanResults .forEach ((result ) => {
248+ console .log (' Content:' , result .content );
249+ console .log (' Format:' , result .format );
250+ });
239251 }
240252 }
241253};
@@ -246,18 +258,23 @@ const scanFromGallery = async () => {
246258``` typescript
247259import ImageCodeScanner , {
248260 BarcodeFormat ,
261+ ScanResult ,
249262} from ' react-native-image-code-scanner' ;
250263
251264// Scan with automatic preprocessing and multiple formats
252- const scanEverything = async (imagePath : string ) => {
265+ const scanEverything = async (imagePath : string ): Promise < ScanResult []> => {
253266 try {
254- const results = await ImageCodeScanner .scan ({
267+ const results: ScanResult [] = await ImageCodeScanner .scan ({
255268 path: imagePath ,
256269 formats: Object .values (BarcodeFormat ), // All supported formats
257270 // Automatic preprocessing is enabled by default
258271 });
259272
260- console .log (` Found ${results .length } barcodes: ` , results );
273+ console .log (` Found ${results .length } barcodes: ` );
274+ results .forEach ((result , index ) => {
275+ console .log (` ${index + 1 }. ${result .format }: ${result .content } ` );
276+ });
277+
261278 return results ;
262279 } catch (error ) {
263280 console .error (' Scan failed:' , error );
@@ -289,7 +306,16 @@ interface ScanOptions {
289306
290307#### Returns
291308
292- ` Promise<string[]> ` - Array of decoded barcode values
309+ ` Promise<ScanResult[]> ` - Array of scan results with content and format information
310+
311+ #### ScanResult
312+
313+ ``` typescript
314+ interface ScanResult {
315+ content: string ; // The decoded barcode content
316+ format: string ; // The detected barcode format (e.g., "QR_CODE", "EAN_13")
317+ }
318+ ```
293319
294320### ` ImageCodeScanner.BarcodeFormat `
295321
@@ -396,8 +422,8 @@ The example app demonstrates:
396422
397423** Platform Support:**
398424
399- - 📱 ** iOS** : Full camera and gallery access
400- - 🤖 ** Android** : Full camera and gallery access
425+ - 📱 ** iOS** : Gallery access
426+ - 🤖 ** Android** : Gallery access
401427
402428## 🤝 Contributing
403429
@@ -413,18 +439,10 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
413439
414440## 📄 License
415441
416- MIT © [ Heimer Nguyen ] ( https://github.com/nguyenthanhan )
442+ MIT
417443
418444## 🆘 Support
419445
420446- 🐛 [ Report Issues] ( https://github.com/nguyenthanhan/react-native-image-code-scanner/issues )
421447- 💬 [ Discussions] ( https://github.com/nguyenthanhan/react-native-image-code-scanner/discussions )
422448- ⭐ Star us on [ GitHub] ( https://github.com/nguyenthanhan/react-native-image-code-scanner )
423-
424- ## 📝 Changelog
425-
426- See [ CHANGELOG.md] ( CHANGELOG.md ) for version history.
427-
428- ---
429-
430- Made with ❤️ by [ Heimer Nguyen] ( https://github.com/nguyenthanhan )
0 commit comments