Skip to main content

NFC Passport Reader | iOS Document Scanner

The Scanbot SDK provides a Near Field Communication (NFC) scanner for reading data from a passport's NFC chip. To use it you should follow these steps:

  • the device you launch your app on should have iOS 13 or higher
  • your app needs to add "Near Field Communication Tag Reading"
  • your app's info.plist needs to provide "Privacy - NFC Scan Usage Description"
  • your app's info.plist needs to define the passport nfc application ID. To do so add the following entry: "com.apple.developer.nfc.readersession.iso7816.select-identifiers" and as the first element add the passport application ID "A0000002471001"

To check if NFC passport reading is available on the system you can call SBSDKNFCPassportReader's class method isPassportReadingAvailable.

You can integrate the component into the application using:

Usage of the Ready to use UI component:#

The main class of the ready to use UI component is SBSDKUINFCPassportReaderViewController.

Usually this view controller is used as a separate screen for reading data from a passport's NFC chip in a UIImage or SampleBufferRef. It returns the recognition results in a delegate method.

While you don't have direct control of the actual scanner view controller you can use the SBSDKUINFCPassportReaderConfiguration to customize it in a variety of ways, such as colors, texts and behavior.

import UIKitimport ScanbotSDK
class NFCPassportReaderUISwiftViewController: UIViewController {
    override func viewDidAppear(_ animated: Bool) {        super.viewDidAppear(animated)
        // Start scanning here. Usually this is an action triggered by some button or menu.        self.startScanning()    }
    func startScanning() {
        // Create the default configuration object.        let configuration = SBSDKUINFCPassportReaderConfiguration.default()
        // Behavior configuration:        // e.g. enable a beep sound on successful detection.        configuration.behaviorConfiguration.isSuccessBeepEnabled = true
        // UI configuration:        // e.g. configure various colors.        configuration.uiConfiguration.topBarBackgroundColor = UIColor.red        configuration.uiConfiguration.topBarButtonsColor = UIColor.white        configuration.uiConfiguration.topBarButtonsInactiveColor = UIColor.white.withAlphaComponent(0.3)
        // Text configuration:        // e.g. customize a UI element's text.        configuration.textConfiguration.cancelButtonTitle = "Cancel"
        // Present the recognizer view controller modally on this view controller.        SBSDKUINFCPassportReaderViewController.present(on: self,                                                       with: configuration, andDelegate: self)    }}
extension NFCPassportReaderUISwiftViewController: SBSDKUINFCPassportReaderViewControllerDelegate {    func nfcPassportReaderViewController(_ viewController: SBSDKUINFCPassportReaderViewController,                                         didFinishWith result: SBSDKUINFCPassportReaderResult) {        // Process the readout result.    }}