Passport SDK integration tutorial cover

How to Integrate a Passport SDK in 10 Minutes (iOS, Android & Web)

Most passport SDK integration tutorials stop at "add the dependency and call the scan method." That leaves developers guessing about permissions, result parsing, error states, and the gap between a demo that works on one device and a production flow that handles real users across hundreds of passport types.

This is a complete passport SDK integration tutorial — not a quickstart. It covers iOS (Swift), Android (Kotlin), and Web (JavaScript) from dependency installation through to a verified, structured result you can pass to your backend. Each platform section follows the same five-step pattern so you can implement one platform now and add another later without relearning the flow.

Before picking a specific vendor, read our Passport SDK Selection guide — it covers the eight questions that determine whether an SDK fits your compliance, accuracy, and deployment requirements. The integration steps below assume you have already made that choice.

What a Passport SDK Actually Does

A passport SDK handles two distinct capture paths that your integration must support:

  1. MRZ scanning: The camera reads the Machine Readable Zone — the two (or three) lines of encoded text at the bottom of the passport's data page — and parses it into structured fields: document number, surname, given names, nationality, date of birth, expiry date, and check digits.
  2. NFC chip reading: On NFC-capable devices, the SDK reads the contactless chip embedded in e-passports, extracts the signed data groups (biography, facial image), and runs Passive Authentication and Chip Authentication to verify the chip has not been tampered with or cloned.

Both paths return the same structured result object. Your integration flow should enable MRZ scanning always, and gate NFC reading on device capability. The SDK's architecture — on-device processing vs. cloud API — also affects where you call it and how you handle connectivity. For a deeper look at that trade-off, see our article on Passport SDK architecture, scalability and security.

Capability MRZ Scan NFC Chip Read
Works offline ✓ Yes ✓ Yes (cert bundle required)
Requires NFC hardware ✓ No ✗ Yes
Detects data tampering ✗ No ✓ Yes (Passive Auth)
Detects chip cloning ✗ No ✓ Yes (Chip Auth)
Returns facial image ✗ No (OCR only) ✓ Yes (DG2)
Supported on all e-passports ✓ Yes ✓ Yes (post-2006 biometric)

iOS Integration (Swift)

1

Install via CocoaPods

iOS · Swift
# Podfile target 'YourApp' do use_frameworks! pod 'PassportSDK', '~> 3.0' end

Run pod install and open the generated .xcworkspace. If you prefer Swift Package Manager, add the SDK's repository URL in Xcode under File → Add Package Dependencies.

2

Configure Info.plist permissions

iOS · Swift
<!-- Info.plist --> <key>NSCameraUsageDescription</key> <string>Scan the passport MRZ to verify your identity</string> <!-- Required only for NFC chip reading --> <key>NFCReaderUsageDescription</key> <string>Read the passport chip to authenticate your document</string> <key>com.apple.developer.nfc.readersession.formats</key> <array> <string>TAG</string> </array>

Also enable the Near Field Communication Tag Reading capability in your Xcode target's Signing & Capabilities tab. Without the entitlement, NFC calls will fail silently at runtime.

3

Initialise the SDK

iOS · Swift
import PassportSDK @main struct MyApp: App { init() { // Initialise once at app startup with your API key PassportSDK.configure( apiKey: "YOUR_API_KEY", environment: .production, enableNFC: true ) } var body: some Scene { WindowGroup { ContentView() } } }
4

Launch the scanner and handle the result

iOS · Swift
import SwiftUI import PassportSDK struct VerifyView: View { @State private var result: PassportResult? @State private var showScanner = false var body: some View { VStack { Button("Scan Passport") { showScanner = true } } .sheet(isPresented: $showScanner) { PassportScannerView( mode: .mrzAndNFC, // .mrzOnly if NFC not needed onSuccess: { scanResult in showScanner = false result = scanResult submitToBackend(scanResult) }, onFailure: { error in showScanner = false handleError(error) } ) } } } // PassportResult fields available after a successful scan: // result.mrz.documentNumber — string // result.mrz.surname — string // result.mrz.givenNames — string // result.mrz.dateOfBirth — Date // result.mrz.expiryDate — Date // result.mrz.nationality — ISO 3166-1 alpha-3 string // result.nfc?.faceImage — UIImage? (DG2, nil if NFC not used) // result.nfc?.authStatus — AuthStatus (.passed / .failed / .notPerformed)
5

Send the result to your backend

iOS · Swift
func submitToBackend(_ result: PassportResult) { guard let payload = try? result.toJSON() else { return } var request = URLRequest(url: URL(string: "https://api.yourapp.com/verify")!) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.httpBody = payload URLSession.shared.dataTask(with: request) { data, _, _ in // Handle backend response }.resume() }

Android Integration (Kotlin)

1

Add the dependency via Gradle

Android · Kotlin
// settings.gradle.kts — add the SDK repository dependencyResolutionManagement { repositories { google() mavenCentral() maven { url = uri("https://sdk.passportsdk.ai/android") } } } // app/build.gradle.kts dependencies { implementation("ai.passportsdk:scanner:3.1.0") }
2

Declare permissions in AndroidManifest.xml

Android · Kotlin
<!-- AndroidManifest.xml --> <uses-permission android:name="android.permission.CAMERA" /> <!-- NFC permissions — remove if NFC is not required --> <uses-permission android:name="android.permission.NFC" /> <uses-feature android:name="android.hardware.nfc" android:required="false" /> <!-- false = optional, app still installs without NFC -->

Setting android:required="false" on the NFC feature keeps your app installable on non-NFC devices. Check for NFC availability at runtime before enabling chip reading.

3

Initialise the SDK in Application

Android · Kotlin
import ai.passportsdk.PassportSDK class MyApplication : Application() { override fun onCreate() { super.onCreate() PassportSDK.init( context = this, apiKey = "YOUR_API_KEY", enableNFC = NfcManager .defaultAdapter(this)?.isEnabled == true ) } }
4

Launch the scanner Activity

Android · Kotlin
class OnboardingActivity : AppCompatActivity() { private val scanLauncher = registerForActivityResult( PassportSDK.ScanContract() ) { result: PassportResult? -> if (result != null) { submitToBackend(result) } else { // User cancelled or scan failed showError() } } fun startPassportScan() { val config = PassportScanConfig( mode = ScanMode.MRZ_AND_NFC, // or ScanMode.MRZ_ONLY locale = "en" ) scanLauncher.launch(config) } fun submitToBackend(result: PassportResult) { // result.mrz.documentNumber, .surname, .givenNames, // .dateOfBirth, .expiryDate, .nationality // result.nfc?.faceImageBitmap — Bitmap? (null if NFC unused) // result.nfc?.authStatus — AuthStatus enum val json = result.toJson() // POST json to your API } }
5

Request camera permission at runtime

Android · Kotlin
private val cameraPermission = registerForActivityResult( ActivityResultContracts.RequestPermission() ) { granted -> if (granted) startPassportScan() else showPermissionRationale() } // Call this before starting the scan: fun checkAndScan() { if (checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { startPassportScan() } else { cameraPermission.launch(Manifest.permission.CAMERA) } }

Web Integration (JavaScript / TypeScript)

The Web SDK ships as a WebAssembly module and runs entirely in the browser. MRZ scanning uses the device's camera via the MediaDevices API. NFC chip reading on the web uses the Web NFC API, currently supported in Chrome on Android only.

1

Install via npm

Web · JavaScript / TypeScript
npm install @passportsdk/web

Or load from a CDN for a script-tag integration:

<script src="https://cdn.passportsdk.ai/web/3.1.0/passportsdk.min.js"></script>
2

Add a mount target to your HTML

Web · JavaScript / TypeScript
<!-- The SDK mounts its camera UI into this container --> <div id="passport-scanner" style="width:100%;max-width:500px;aspect-ratio:4/3;"></div> <button id="scan-btn">Scan Passport</button>
3

Initialise and launch

Web · JavaScript / TypeScript
import { PassportScanner } from '@passportsdk/web'; const scanner = new PassportScanner({ apiKey: 'YOUR_API_KEY', container: '#passport-scanner', mode: 'mrz', // 'mrz' | 'mrz-nfc' (NFC: Chrome Android only) language: 'en', }); document.getElementById('scan-btn') .addEventListener('click', async () => { try { const result = await scanner.scan(); submitToBackend(result); } catch (err) { handleError(err); } });
4

Parse and submit the result

Web · JavaScript / TypeScript
async function submitToBackend(result) { // result.mrz.documentNumber — string // result.mrz.surname — string // result.mrz.givenNames — string // result.mrz.dateOfBirth — ISO 8601 string // result.mrz.expiryDate — ISO 8601 string // result.mrz.nationality — ISO 3166-1 alpha-3 // result.nfc?.faceImageB64 — base64 JPEG string (if NFC used) // result.nfc?.authStatus — 'passed' | 'failed' | 'not_performed' const response = await fetch('/api/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(result), }); const json = await response.json(); // Handle onboarding outcome } function handleError(err) { if (err.code === 'CAMERA_DENIED') { showMessage('Camera access is required to scan your passport.'); } else if (err.code === 'SCAN_TIMEOUT') { showMessage('Scan timed out. Please try in better lighting.'); } else { showMessage('Something went wrong. Please try again.'); } }
5

HTTPS is mandatory

Web · JavaScript / TypeScript

Browsers block camera and NFC access on non-secure origins. Your integration page must be served over HTTPS. localhost is treated as secure during development and does not require a certificate.

Cross-Platform: React Native and Flutter

If your app targets both iOS and Android from a single codebase, use the official React Native or Flutter plugin rather than writing separate native integrations.

React Native
npm install react-native-passport-sdk # iOS: run pod install inside /ios after installing # Android: no additional step — Gradle resolves automatically
import { scanPassport } from 'react-native-passport-sdk'; async function handleScan() { try { const result = await scanPassport({ mode: 'mrz-nfc' }); submitToBackend(result); } catch (e) { console.error(e); } }
Flutter
# pubspec.yaml dependencies: passport_sdk_flutter: ^3.1.0
import 'package:passport_sdk_flutter/passport_sdk_flutter.dart'; Future<void> handleScan() async { final result = await PassportSDK.scan(mode: ScanMode.mrzAndNfc); if (result != null) submitToBackend(result); }

Production Checklist Before You Ship

A working prototype and a production-ready integration are not the same thing. Before you go live, confirm each of the following:

  • API key scoped to production: Development and production keys should be separate. Production keys should be stored in a secrets manager, not in your source code.
  • Camera permission rationale: On Android, always show a rationale dialog before requesting the permission if the user has previously denied it. On iOS, you only get one prompt — make the Info.plist string descriptive.
  • Error states handled for every code: At minimum: CAMERA_DENIED, SCAN_TIMEOUT, MRZ_NOT_FOUND, NFC_NOT_SUPPORTED, NFC_READ_ERROR, and CHIP_AUTH_FAILED. Map each to a user-facing message that explains the next step.
  • NFC gracefully disabled on unsupported devices: Fall back to MRZ-only mode on devices without NFC hardware. Do not hard-require chip reading unless your compliance tier demands it.
  • Backend validates the SDK token: The SDK returns a signed result token. Your backend should verify the token's signature using the SDK provider's public key before trusting any of the extracted data. Never trust raw client-side data without server-side verification.
  • Certificate store is up to date: If you ship a bundled certificate store for offline NFC authentication, include a background update mechanism or plan for app releases that refresh it. An outdated store will reject legitimate passports as their signing certificates age out.
  • Tested on real passports: Test with passports from at least five different issuing countries, including both pre-2006 non-biometric passports (MRZ only) and post-2006 e-passports (NFC capable). Edge cases in name formatting and date encoding vary significantly across issuing authorities.

For a deeper look at how on-device and cloud processing architectures affect production reliability, scalability, and compliance, see our article on Cloud vs. On-Premise Passport SDK deployment models.

Common Integration Mistakes

These are the issues that consistently appear in developer forums after initial integration.

  • Calling the SDK before permission is granted: The SDK will throw or return an error immediately. Always confirm camera (and NFC, if used) permission before launching the scanner, even if you think the user already granted it.
  • Mounting the scanner into a zero-height container: On the web, if the mount container has no explicit height, the camera feed will not render. Always set an explicit height or aspect-ratio on the container element.
  • Treating MRZ check digit failure as a scan error: A failed check digit means the OCR read one or more characters incorrectly, not that the passport is invalid. The right response is to restart the scan, not to reject the document or surface an error to the user.
  • Not handling NFC_NOT_SUPPORTED on Android: Even if the device has NFC hardware, the adapter can be disabled by the user. Check adapter state at runtime, not just hardware availability.
  • Storing raw passport data in client storage: Do not persist MRZ strings, document numbers, or facial images in localStorage, SharedPreferences, or NSUserDefaults. Pass the result to your backend immediately and discard it from device memory.

What to Do After Integration: Choosing the Right SDK Features

Once the basic integration is working, the next decision is which SDK features to enable based on your specific use case. Not every deployment needs NFC chip reading, liveness detection, or document fraud checks. Enabling features you do not need increases friction for your users without improving your security posture.

The key questions are: what tier of identity assurance does your regulatory context require, and what is the minimum friction path that meets it? Our Passport SDK Selection guide walks through that decision systematically — covering accuracy benchmarks, compliance requirements, and the features that actually matter for each use case.

For teams considering whether their architecture should run processing on-device or in the cloud, the trade-offs between latency, data residency, offline capability, and certificate management are covered in our piece on Passport SDK architecture and scalability.

Frequently Asked Questions

How long does a passport SDK integration actually take?

For a well-documented SDK with native packages available via CocoaPods, Gradle, or npm, a working prototype that scans a passport and returns structured data typically takes under 30 minutes. A production-ready integration — with error handling, UI polish, and server-side verification calls — takes one to three developer days depending on platform and the complexity of your existing onboarding flow.

Does a passport SDK work offline?

MRZ scanning and data extraction can run entirely on-device with no network call. NFC chip reading also runs on-device. However, certificate chain validation for e-passport authentication requires an up-to-date certificate store — most SDKs handle this by bundling a periodically updated certificate package or by making a background sync call, rather than requiring a live connection at scan time.

Which platforms does a passport SDK support?

Production-grade passport SDKs support iOS (Swift/Objective-C), Android (Kotlin/Java), and Web (JavaScript/TypeScript via WebAssembly). React Native and Flutter wrappers are also available from most vendors, exposing the native SDK through a cross-platform bridge.

What permissions does a passport SDK need?

Camera permission is required for MRZ scanning on all platforms. NFC permission is required if you enable chip reading. Web integrations require the user to grant camera access via the browser permission prompt; NFC on the web requires Chrome on Android with the Web NFC API.

Can I integrate a passport SDK into a React Native or Flutter app?

Yes. Most passport SDK vendors publish official React Native and Flutter plugins that wrap the underlying native SDK. The plugin exposes a JavaScript or Dart API that mirrors the native interface, so you can call scanPassport() from cross-platform code while the native camera and NFC hardware handles the actual scanning.

Conclusion

A passport SDK integration follows the same five-step pattern on every platform: install the dependency, declare permissions, initialise with your API key, launch the scanner, and handle the structured result. The code in this guide gives you a working starting point for iOS, Android, and Web, and covers the production concerns — error handling, permission flows, backend verification, and certificate management — that the quickstart tutorials leave out.

The underlying complexity of MRZ parsing, NFC protocol negotiation, and e-passport authentication is handled entirely by the SDK. What your application code needs to do is configure it, launch it, receive the result, and make a good decision about what comes next in your onboarding flow.

If you are still evaluating which SDK to build on, start with our Passport SDK Selection guide before writing any integration code. Choosing the right SDK before you integrate is far less expensive than switching after you have built against the wrong one.