### Install iOS Dependencies Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Navigate to the ios directory and run 'pod install' to install iOS dependencies for the BlinkID plugin. ```bash pod install ``` -------------------------------- ### Install Watchman Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Install Watchman using Homebrew. This is a dependency for running the sample application. ```bash brew install watchman ``` -------------------------------- ### Install Node.js Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Install Node.js using Homebrew. This is a dependency for running the sample application. ```bash brew install node ``` -------------------------------- ### Start React Native Packager Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Start the React Native development server. This is often a prerequisite for running the application on Android or iOS, and can be used in conjunction with Android Studio for debugging. ```bash npx react-native start ``` -------------------------------- ### Install BlinkID React Native Dependency Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Install the BlinkID React Native library using npm. ```bash npm install --save @microblink/blinkid-react-native ``` -------------------------------- ### Install New BlinkID React Native Package Source: https://github.com/microblink/blinkid-react-native/blob/master/Release notes.md Use this command to install the new BlinkID React Native package, as the old one is deprecated. This ensures you receive the latest features and improvements. ```bash npm install @microblink/blinkid-react-native ``` -------------------------------- ### Initialize React Native Project Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Use this command to create a new React Native project with specified package name, title, and React Native version. ```bash npx @react-native-community/cli init YourAppName --package-name YourPackageName --title YourAppTitle --version "React Native version" ``` -------------------------------- ### Initialize BlinkID React Native Sample Application Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Run the initialization script for the BlinkID React Native sample application after cloning the repository. This script sets up the necessary dependencies and configurations. ```bash cd blinkid-react-native && ./initBlinkIdReactNativeSample.sh ``` -------------------------------- ### Configure BlinkID SDK Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Initialize BlinkID SDK settings, including enabling resource downloads and setting the license key. This is a prerequisite for scanning operations. ```typescript /** * Set the BlinkID SDK settings * Add the license key here from the code above */ const sdkSettings = new BlinkIdSdkSettings(licenseKey); sdkSettings.downloadResources = true; ``` -------------------------------- ### Run BlinkID React Native Sample on Android Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Execute this command to run the BlinkID React Native sample application on an Android device or emulator. Ensure you are in the `BlinkIdSample` directory. ```bash npx react-native run-android ``` -------------------------------- ### performScan Method Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Launches the BlinkID scanning process with default UX properties. It accepts SDK settings, session settings, optional UI settings, and an optional ClassFilter for document filtering. ```APIDOC ## performScan ### Description Launches the BlinkID scanning process with the default UX properties. ### Parameters 1. **BlinkIdSdkSettings** - `BlinkIdSdkSettings`: Contains SDK settings including license key and model acquisition. 2. **BlinkIdSessionSettings** - `BlinkIdSessionSettings`: Contains settings for the scanning session, including `ScanningMode` and `BlinkIdScanningSettings`. 3. **BlinkIdUiSettings** (Optional) - `BlinkIdUiSettings`: Allows customization of the UI during the scanning process. 4. **ClassFilter** (Optional) - `ClassFilter`: Controls which documents are accepted or rejected for information extraction. ``` -------------------------------- ### Configure BlinkID Session Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Set up session settings for BlinkID, including the scanning mode. For DirectAPI with two images, use 'Automatic' mode. ```typescript /** * Create and modify the Session Settings */ const sessionSettings = new BlinkIdSessionSettings(); sessionSettings.scanningMode = ScanningMode.Automatic; ``` -------------------------------- ### Configure BlinkID DirectAPI Session Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Set up session settings for BlinkID DirectAPI, specifying the scanning mode. Use 'Automatic' for two images and 'Single' for one image. ```typescript /** * Create and modify the Session Settings */ const sessionSettings = new BlinkIdSessionSettings(); /** * Important: if two images are being passed, use the `Automatic` * scanning mode * if just one image is being passed, use the `Single` scanning mode. */ sessionSettings.scanningMode = ScanningMode.Automatic; ``` -------------------------------- ### Configure Android Maven Repository Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Ensure the mavenCentral() repository is included in your project's build.gradle file to access the BlinkID library. ```bash repositories { // ... other repositories mavenCentral() } ``` -------------------------------- ### Configure BlinkID UI Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Customize the BlinkID user interface by enabling/disabling elements like the help button and onboarding dialog, and setting the preferred camera. ```typescript /** * Modify the BlinkID UI settings for UI customization. * This parameter is optional. */ const blinkIdScanningUxSettings = new BlinkIdScanningUxSettings(); blinkIdScanningUxSettings.showHelpButton = true; blinkIdScanningUxSettings.showOnboardingDialog = true; blinkIdScanningUxSettings.allowHapticFeedback = true; blinkIdScanningUxSettings.preferredCamera = PreferredCamera.Back; ``` -------------------------------- ### Configure Scanning Settings for BlinkID Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Set up cropped image settings and scanning settings within the session settings. Ensure all necessary configurations are in place before initiating a scan. ```typescript scanningSettings.croppedImageSettings = croppedImageSettings; sessionSettings.scanningSettings = scanningSettings; const firstImageBase64 = "your-base64-image"; const secondImageBase64 = "your-base64-image"; ``` -------------------------------- ### Clone BlinkID React Native Repository Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Clone the BlinkID React Native repository to your local machine to access the plugin and sample application. ```bash git clone https://github.com/microblink/blinkid-react-native.git ``` -------------------------------- ### Configure BlinkID Cropped Image Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Define settings for cropped images, specifying which images (document, face, signature) should be returned. These are then placed within the scanning settings. ```typescript /** * Create and modify the Image settings */ const croppedImageSettings = new CroppedImageSettings(); croppedImageSettings.returnDocumentImage = true; croppedImageSettings.returnFaceImage = true; croppedImageSettings.returnSignatureImage = true; /** * Place the image settings in the scanning settings */ scanningSettings.croppedImageSettings = croppedImageSettings; ``` -------------------------------- ### performDirectApiScanning Method Source: https://github.com/microblink/blinkid-react-native/blob/master/Release notes.md Initiates the BlinkID scanning process for extracting information from static images. It requires SDK settings, session settings, and base64 encoded image strings. ```APIDOC ## performDirectApiScan ### Description Launches the BlinkID scanning process intended for information extraction from static images. ### Parameters 1. **BlinkIdSdkSettings** (`BlinkIdSdkSettings`): Contains SDK settings including license key and model acquisition. 2. **BlinkIdSessionSettings** (`BlinkIdSessionSettings`): Contains settings for the scanning session, including `ScanningMode` and `BlinkIdScanningSettings`. 3. **string**: The first image string in Base64 format. For `automatic` `ScanningMode`, this should be the front side. For `single` `ScanningMode`, it can be either side. 4. **string**: Optional. The second image string in Base64 format, required for the back side if `ScanningMode` is `automatic`. ### Returns - **BlinkIdScanningResult**: An object containing the results of the document scan, including extracted data and images. ``` -------------------------------- ### Configure BlinkID Scanning Settings Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Customize scanning settings such as glare detection level and anonymization mode. Optionally, enable scanning of cropped document images for DirectAPI. ```typescript /** * Create and modify the scanning settings */ const scanningSettings = new BlinkIdScanningSettings(); scanningSettings.glareDetectionLevel = DetectionLevel.Mid; scanningSettings.anonymizationMode = AnonymizationMode.FullResult; /** * if the input images consist solely * of the cropped document image, set the * `scanCroppedDocumentImage` to true. */ // scanningSettings.scanCroppedDocumentImage = true; ``` -------------------------------- ### Set License Key Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Define the license key for both iOS and Android platforms. Obtain your keys from the Microblink Developer Hub portal. ```typescript const licenseKey = Platform.select({ ios: 'your-ios-key', android: 'your-android-key', }); ``` -------------------------------- ### performDirectApiScan Method Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Initiates the BlinkID scanning process for extracting information from static images. It requires SDK settings, session settings, and base64 encoded image strings. ```APIDOC ## performDirectApiScan ### Description Launches the BlinkID scanning process intended for information extraction from static images. ### Parameters 1. **BlinkIdSdkSettings** - `BlinkIdSdkSettings`: Contains SDK settings including license key and model acquisition. 2. **BlinkIdSessionSettings** - `BlinkIdSessionSettings`: Contains settings for the scanning session, including `ScanningMode` and `BlinkIdScanningSettings`. 3. **First Image String** - `String`: Base64 encoded string of the first image (e.g., front side of a document). 4. **Second Image String** (Optional) - `String`: Base64 encoded string of the second image (e.g., back side of a document, required for automatic scanning mode if back side information is needed). ``` -------------------------------- ### Configure BlinkID Document Class Filter Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Optionally, set a document class filter to specify which countries, regions, and document types should be included in the scan. ```typescript /** * Add the document class filter. This parameter is optional. */ const classFilter = new ClassFilter(); classFilter.includeDocuments = [ new DocumentFilter(Country.Croatia, undefined, DocumentType.Id), new DocumentFilter(Country.USA, Region.Texas, DocumentType.Dl), ]; ``` -------------------------------- ### Import BlinkID Plugin Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Import the necessary functions from the BlinkID React Native plugin. Ensure this is done before using any plugin functionalities. ```typescript import { performScan, performDirectApiScan, } from '@microblink/blinkid-react-native'; ``` -------------------------------- ### Scan Document with DirectAPI (Multiside) Source: https://github.com/microblink/blinkid-react-native/blob/master/Release notes.md Use this method to extract document information from static images without using the device camera. It requires a recognizer collection, front image, optional back image, and license keys. ```javascript const blinkIdRecognizer = await BlinkIDRecognizer.createRecognizer(); const recognizerCollection = await RecognizerCollection.createRecognizerCollection([blinkIdRecognizer]); const result = await NativeModules.BlinkIDModule.scanWithDirectApi( recognizerCollection, frontImageBase64, backImageBase64, licenseKeys ); ``` -------------------------------- ### Scan Document with DirectAPI (Singleside) Source: https://github.com/microblink/blinkid-react-native/blob/master/Release notes.md This variant of DirectAPI scanning is for single-sided documents. The back image parameter is optional and can be null or an empty string. ```javascript const blinkIdSingleSideRecognizer = await BlinkIdSingleSideRecognizer.createRecognizer(); const recognizerCollection = await RecognizerCollection.createRecognizerCollection([blinkIdSingleSideRecognizer]); const result = await NativeModules.BlinkIDModule.scanWithDirectApi( recognizerCollection, frontImageBase64, null, // backImage is optional for single-side scanning licenseKeys ); ``` -------------------------------- ### Perform BlinkID Scan Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Call the `performScan` method with the configured SDK, session, and UI settings. Handle the results or any errors that occur during the scan process. ```typescript /** * Call the performScan method, where the SDK and session settings * need to be passed. * * Here, you can also pass the optional BlinkIdUiSettings and ClassFilter * parameters. */ await performScan(sdkSettings, sessionSettings, blinkIdScanningUxSettings) .then((result: BlinkIdScanningResult) => { // handle the results here. console.log(result.firstName?.value); }) .catch((error) => { // handle any errors here. console.log(`Error during scan: ${error}`); }); ``` -------------------------------- ### Perform Direct API Scan with BlinkID Source: https://github.com/microblink/blinkid-react-native/blob/master/README.md Call the performDirectApiScan method with SDK settings, session settings, and Base64 encoded images. Handle the scan results or any errors that occur during the process. ```typescript await performDirectApiScan( sdkSettings, sessionSettings, firstImageBase64, secondImageBase64 ) .then((result: BlinkIdScanningResult) => { //handle the results here. console.log(result.firstName?.value); }) .catch((error) => { // handle any errors here. console.log(`Error during scan: ${error}`); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.