passportscanner

Introduction

Welcome to the PassportScanner documentation. This library allows you to easily integrate passport scanning capabilities into your iOS application. With PassportScanner, you can extract relevant information from a passport’s machine-readable zone (MRZ).

Installation

Follow these steps to install PassportScanner in your iOS project:

  1. Open your project in Xcode.
  2. Go to File > Swift Packages > Add Package Dependency.
  3. Enter the package repository URL: https://github.com/originalapplab/PassportScanner.git
  4. Click Next.
  5. Choose the version rule and click Next again.
  6. Finally, click Finish to add the package dependency to your project.

Usage

To use PassportScanner in your application, follow these steps:

Step 1: Import the library

First, import the PassportScanner library into your Swift file:

// Import PassportScanner
import PassportScanner

Step 2: Acquire an image of the passport

You need to acquire an image of the passport to extract the information from the MRZ. This can be done using the camera or by using an existing image file. Here is an example of capturing an image using the camera:

// Create an instance of PassportScannerViewController
let scannerViewController = PassportScannerViewController()

// Set the delegate
scannerViewController.delegate = self

// Present the scanner view controller
self.present(scannerViewController, animated: true, completion: nil)

Step 3: Implement PassportScannerDelegate

In your view controller, implement the PassportScannerDelegate protocol to receive the extracted MRZ information:

class MyViewController: UIViewController, PassportScannerDelegate {
    
    // Implement the delegate method to receive the extracted MRZ information
    func passportScannerDidFinishScanning(with result: PassportScannerResult) {
        // Access the extracted MRZ information
        let firstName = result.firstName
        let lastName = result.lastName
        let passportNumber = result.passportNumber
        let nationality = result.nationality
        
        // TODO: Use the extracted information as needed
    }
    
    // ...
}

Step 4: Dismiss the scanner view controller

After the scanning process is completed, you can dismiss the scanner view controller:

scannerViewController.dismiss(animated: true, completion: nil)

Additional Information

Supported Formats

  • Passport
  • Visa

Requirements

PassportScanner requires the following:

  • iOS 13.0 or later
  • Xcode 11 or later

In-app Permissions

To use the PassportScanner library, your application must request the necessary user permissions:

  • Camera – To capture passport images

Conclusion

Congratulations! You have successfully integrated PassportScanner into your iOS application. You can now extract relevant information from a passport’s MRZ with ease. If you have any questions or issues, please refer to the documentation or reach out to our support team.