### Start the development packager Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Starts the Metro bundler for the example application. ```sh yarn example start ``` -------------------------------- ### Run example app on Android Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. ```sh yarn example android ``` -------------------------------- ### Install dependencies Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Run this command in the root directory to install dependencies for all packages. ```sh yarn ``` -------------------------------- ### Install via Expo Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Commands to install the package and prepare the native project for Expo. ```bash npx expo install react-native-image-code-scanner npx expo prebuild --clean npx expo run:ios # or: npx expo run:android ``` -------------------------------- ### Run example app on iOS Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS device or simulator. ```sh yarn example ios ``` -------------------------------- ### Install dependencies Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Install project dependencies from the repository root. ```bash yarn install ``` -------------------------------- ### Start Metro development server Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Launch the Expo development server with the dev client enabled. ```bash yarn expo start --clear --dev-client --host localhost ``` -------------------------------- ### Verify new architecture logs Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Example log output confirming the app is running with the new architecture enabled. ```text Running "ImageCodeScannerExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1} ``` -------------------------------- ### Install TypeScript Definitions Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Install compatible type definitions to resolve TypeScript errors in React Native 0.7x. ```bash npm install --save-dev @types/react@^18.0.0 @types/react-native@^0.72.0 ``` -------------------------------- ### Install via React Native CLI Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Commands to install the package and update iOS pods for React Native CLI projects. ```bash yarn add react-native-image-code-scanner cd ios && pod install ``` -------------------------------- ### Scan Images for Barcodes Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Example implementation using expo-image-picker to select an image and scan it for specific barcode formats. ```ts import * as ImagePicker from 'expo-image-picker'; import ImageCodeScanner, { BarcodeFormat, } from 'react-native-image-code-scanner'; async function pickAndScan() { const picked = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, quality: 1, }); if (picked.canceled || !picked.assets?.[0]?.uri) return []; const results = await ImageCodeScanner.scan({ path: picked.assets[0].uri, formats: [BarcodeFormat.QR_CODE, BarcodeFormat.CODE_128], }); // results is ScanResult[] — may contain 0, 1, or many barcodes return results; } ``` -------------------------------- ### Build and run iOS Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Commands to clean, prebuild, and run the iOS application. ```bash cd example yarn expo prebuild --clean --platform ios yarn expo run:ios --no-build-cache ``` ```bash cd example yarn expo run:ios --no-bundler --no-build-cache ``` -------------------------------- ### Build and run Android Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Commands to clean, prebuild, and run the Android application. ```bash cd example yarn expo prebuild --clean --platform android yarn expo run:android --no-build-cache ``` ```bash cd example yarn expo run:android --no-bundler --no-build-cache ``` -------------------------------- ### Initialize Test Application Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Commands to initialize a test project with a specific React Native version. ```bash # Test with specific React Native version npx react-native init TestApp --version 0.79.2 cd TestApp npm install react-native-image-code-scanner ``` -------------------------------- ### Run project quality checks Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Execute type checking, linting, testing, and building before publishing. ```bash yarn typecheck yarn lint yarn test yarn build ``` -------------------------------- ### Create and push a beta release Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Performs a beta version release and pushes the resulting commit and tags. ```bash yarn release:beta git push && git push --tags ``` -------------------------------- ### Verify iOS New Architecture Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Check the Podfile properties to confirm the New Architecture is enabled. ```bash cat ios/Podfile.properties.json # expect: "newArchEnabled": "true" ``` -------------------------------- ### Publish new version Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Uses release-it to automate the versioning and publishing process. ```sh yarn release ``` -------------------------------- ### Verify Android New Architecture Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Check the gradle properties to confirm the New Architecture is enabled. ```bash grep newArchEnabled android/gradle.properties # expect: newArchEnabled=true ``` -------------------------------- ### Expo Prebuild Commands Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Commands required to use the library with Expo by generating native modules. ```bash npx expo prebuild npx expo run:ios # or run:android ``` -------------------------------- ### Run unit tests Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Executes the project's test suite using Jest. ```sh yarn test ``` -------------------------------- ### Enable New Architecture Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/example/README.md Configure the Expo project to use the New Architecture in app.json. ```json { "expo": { "newArchEnabled": true } } ``` -------------------------------- ### Configuring New Architecture for React Native 0.70-0.75 Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Commands and properties to enable the New Architecture on iOS and Android for specific React Native versions. ```bash # iOS cd ios && RCT_NEW_ARCH_ENABLED=1 pod install # Android - in gradle.properties newArchEnabled=true ``` -------------------------------- ### Configure Camera Permissions Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Required Info.plist entry for apps that access the camera to scan barcodes. ```xml NSCameraUsageDescription This app needs camera access to scan barcodes ``` -------------------------------- ### Run type checking and linting Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Verifies code quality and type safety using TypeScript and ESLint. ```sh yarn typecheck yarn lint ``` -------------------------------- ### Push release commit and tags Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Uploads the release commit and associated tags to the remote repository. ```bash git push && git push --tags ``` -------------------------------- ### Verify published version Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Checks the current version of the package on the npm registry. ```bash npm view react-native-image-code-scanner version ``` -------------------------------- ### Fix linting errors Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/CONTRIBUTING.md Automatically fixes formatting and linting issues. ```sh yarn lint --fix ``` -------------------------------- ### Importing Turbo Module Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md The library automatically utilizes Turbo Modules when the New Architecture is enabled in the project. ```typescript // Automatically uses Turbo Module when New Architecture is enabled import ImageCodeScanner from 'react-native-image-code-scanner'; ``` -------------------------------- ### Scan Image API Usage Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md The library uses a unified API for both Old and New architectures. ```typescript // Same API for both architectures const results = await ImageCodeScanner.scan({ path: imagePath, formats: [BarcodeFormat.QR_CODE], }); ``` -------------------------------- ### ImageCodeScanner.scan Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Scans an image file for barcodes and returns an array of detected results. ```APIDOC ## ImageCodeScanner.scan(options: ScanOptions) ### Description Scans the provided image path for barcodes. It supports multiple barcode formats and performs automatic preprocessing by default. ### Parameters #### ScanOptions - **path** (string) - Required - The file path of the image to scan. - **formats** (BarcodeFormat[]) - Optional - Array of formats to look for. Default: [QR_CODE]. - **enhanceContrast** (boolean) - Optional - Whether to enhance image contrast. Default: true. - **convertToGrayscale** (boolean) - Optional - Whether to convert image to grayscale. Default: true. - **tryRotations** (boolean) - Optional - Whether to attempt rotation retries. Default: true. ### Response Returns a Promise that resolves to an array of ScanResult objects. #### ScanResult - **content** (string) - The decoded content of the barcode. - **format** (string) - The format of the detected barcode. ``` -------------------------------- ### Update Peer Dependencies Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Required peer dependency versions when upgrading from React Native 0.6x to 0.7x. ```json { "react": ">=17.0.0", "react-native": ">=0.70.0" } ``` -------------------------------- ### Scan API and Interface Definitions Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/README.md Defines the primary scan method and the structure for scan options and results. ```ts ImageCodeScanner.scan(options: ScanOptions): Promise interface ScanOptions { path: string; formats?: BarcodeFormat[]; // default: [QR_CODE] enhanceContrast?: boolean; // default: true convertToGrayscale?: boolean; // default: true tryRotations?: boolean; // default: true } interface ScanResult { content: string; format: string; // no bounding-box coordinates } ``` -------------------------------- ### Disabling New Architecture for React Native 0.76+ Source: https://github.com/anngth/react-native-image-code-scanner/blob/main/COMPATIBILITY.md Commands and properties to disable the New Architecture, which is enabled by default in newer React Native versions. ```bash # iOS cd ios && RCT_NEW_ARCH_ENABLED=0 pod install # Android - in gradle.properties newArchEnabled=false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.