iOS identity SDK

Embed identity verification into your iOS app using our native SDK.

Prerequisites

Sign up for an account — It's free.

Sign in to your account and generate a public key and secret. For security purposes, the secret is only shown once, so make sure to save it and keep it in a safe place. If you lose your secret you can generate a new one.

Integration at a glance

With this integration you will embed our technology into your own iOS app. Our UX components blend with yours and the user will go through the necessary steps without leaving your app.

On a high level, this integration has three main steps:
• Create a session using the Session API.
• Start the session in your app using the native SDK and the token created in the previous step.
• Use the Session API to retrieve the identity data when the SDK completes.

Note that there is no sandbox environment for testing, instead, integration and testing is done in production.
When you sign up for an account you can use the Developer plan for this.

Step 1 — Create a session

Start by creating a new session from your backend system:
# requestcurl http://localhost:4000/api/v2/session.create \ -u key:secret \ -d @- << EOF{ "face_verification": false, "passport_only": false}EOF # response{ "id": 123, "token": "i_dI5hs7m...", ...}
Optional properties:
• reference — set a reference to connect the session to any arbitrary identifier, such as a user id or a session id from your own system.
• face_verification — set whether face verification is required or not (false by default).
• passport_only — set whether only passports should be accepted, excluding national ID cards (false by default).

Send the token to your application. The SDK reads the API host and flow settings from the token.

Note that a session is intended to be used for a short period of time to handle a single user. Once a session has been used, it should not be used again.

Step 2 — SDK integration on iOS

Download the SDK (PassportReader.xcframework) for iOS and add it to your Xcode project.
Both Swift and Objective-C are supported. Minimum target iOS 16.0.

To add a framework to an iOS application, follow these steps:
• Open the app's Xcode project or workspace.
• Go to the app target's General configuration page.
• Add PassportReader.xcframework to Frameworks, Libraries, and Embedded Content.
• Make sure the framework is embedded and signed by the app target.

The app will need the following entitlement:
<key>com.apple.developer.nfc.readersession.formats</key><array> <string>TAG</string></array>
And the following entries in Info.plist:
<key>NFCReaderUsageDescription</key><string>For reading and processing passports and ID cards</string><key>NSCameraUsageDescription</key><string>For reading and processing passports and ID cards</string><key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key><array> <string>A0000002471001</string></array>
Next, import the SDK and create a BackendSession using the token from the previous step. At some point before starting the session, request permission to use the camera (this is not handled by the SDK).

Start the session.
// integration example in Swiftimport PassportReader let passportReader = PassportReader()guard let session = BackendSession(token: token) else { // handle an invalid token return} passportReader.start( in: windowScene, session: session, completion: { // retrieve the session results from your backend }, failure: { error in // handle error, e.g. retry by calling start again }, cancellation: { // cancelled by the user })
BackendSession reads the API host, passport_only, and face_verification from the token. You do not need to decode the token or pass those settings to start. The initializer returns nil for an invalid token. Use session.id if your app needs the session identifier for display or tracking.

BackendSession handles communication with the backend. When face verification is enabled, verification runs on the device and the resulting face evidence is uploaded on success.

The completion callback has no arguments. Retrieve identity data through the Session API as shown in the next step.

Step 3 — Retrieve identity data

When the SDK completion callback fires, use the Session API to retrieve the identity data in your backend system.
# requestcurl http://localhost:4000/api/v2/session.get \ -u key:secret \ -d @- << EOF{ "id": 123}EOF # response{ "state": "COMPLETED", ... "given_names": "John", "surname": "Doe", "nationality": "US", "sex": "MALE", "date_of_birth": "1988-01-01", "personal_number": "...", "place_of_birth": "...", "optional_data": "...", "optional_data2": "...", "document_type": "PASSPORT", "document_number": "31195855", "expiry_date": "2031-01-01", "issuing_country": "US", "issuer": "Department of State, U.S. Government", "portrait": "dGVzdHRlc3R0ZXN0...", "document_integrity_verified": true, "active_authentication": true, "chip_authentication": true, ...}
If face verification was required, an additional property will be available; face — containing an image of the user's face.
Retrieve the results before the session's expires timestamp. After expiry, the results are no longer available through the API, even if scheduled cleanup has not yet removed the stored data.
COMPLETED means the verification flow has completed. It does not mean the identity has been approved.

Before accepting the result, check document_integrity_verified, confirm that csca_certificate_fingerprint identifies an issuer certificate you trust, and check the document's expiry date. Apply your requirements for active_authentication, chip_authentication, and face verification. Your system makes the final acceptance decision.

On-device processing

To process documents on the device, use LocalChipReaderSession and LocalFaceVerificationSession with the separate scanning methods. This flow does not require a token or a session created through the Session API. Results are returned directly to your app and are not uploaded by these local sessions.

Keep the camera permission and platform setup described above. The example disables SDK telemetry with the PassportReader constructor.

First scan the MRZ to obtain the chip access keys, then read and verify the chip using a local session. Supply your trusted CSCA certificates as DER-encoded data. You maintain this certificate collection; an empty collection does not establish trust in the document issuer.
import PassportReader let passportReader = PassportReader(telemetry: false)// DER-encoded certificates from your trusted CSCA certificate collection.let cscaCertificates: [Data] = trustedCertificateslet chipSession = LocalChipReaderSession(cscaCertificates: cscaCertificates) passportReader.startMRZScanner( in: windowScene, completion: { keys in passportReader.startChipReader( in: windowScene, session: chipSession, keys: keys, passportOnly: false, completion: { givenNames, surname, dateOfBirth, nationality, sex, documentNumber, documentType, expiryDate, issuingCountry, issuer, optionalData, optionalData2, portrait, personalNumber, placeOfBirth, dsc, documentIntegrityVerified, chipAuthentication, activeAuthentication, smProtocol, efCardaccess, efCardsecurity, efSod, efDg1, efDg2, efDg11, efDg14, efDg15 in // use the identity data and authentication results // retain portrait for face verification }, failure: { error in // handle chip reading or verification failure }, cancellation: { // cancelled by the user } ) }, failure: { // handle MRZ scanning failure }, cancellation: { // cancelled by the user })
The chip completion callback returns identity data, authentication results, the original portrait, and the EF files read from the document. Apply your acceptance checks to the authentication results and document data.

Pass the original portrait to face verification. For display, convert it separately using PassportReader.portraitToPNG(portrait).

After chip reading completes, you can start local face verification using the returned portrait:
let faceSession = LocalFaceVerificationSession() passportReader.startFaceVerification( in: windowScene, session: faceSession, portrait: portrait, completion: { face, score, frames in // face is a PNG image; frames contains the captured evidence // an empty face means verification did not succeed }, failure: { // handle face verification failure }, cancellation: { // cancelled by the user })
The face completion callback returns a PNG image, a score, and the captured frames. Check that the face image is nonempty before treating verification as successful. Your app controls how local results and evidence are stored or sent to your own backend.

Customizing the implementation

The SDK accepts implementations of its public protocols so you can adapt networking, session management, and verification to your application.

Implement HTTPClient to use your own networking stack with BackendSession. Its post(_:headers:body:completion:) method receives the URL, headers, and sealed request bytes. Send those headers and bytes unchanged, then call completion(statusCode, data) once with the HTTP status and raw response bytes. Use status 0 for a transport failure. BackendSession handles request sealing and retries.

Given your own MyHTTPClient implementation, inject it when creating the session:
guard let session = BackendSession( token: token, httpClient: MyHTTPClient()) else { // handle an invalid token return}
To customize more than networking, implement the session protocols:

• Session — pass your implementation to PassportReader.start for the complete flow. It combines ChipReaderSession and FaceVerificationSession with session initiation, failure, and cancellation handling.
• ChipReaderSession — pass your implementation to startChipReader to control chip authentication operations and verification of the files read from the document.
• FaceVerificationSession — pass your implementation to startFaceVerification to control verification of the portrait and captured frames.

Expose the passportOnly and faceVerification properties on your custom Session to configure the complete flow. Your implementations can delegate operations to the local session classes or communicate with your own backend. Implement all required methods and return results through the supplied callbacks. Keep chip authentication state in the same session instance throughout a read.
You can implement your own backend operations using libpassportreader, our native library with a C interface. It provides chip authentication, certificate and document verification, face verification, and envelope processing. Your custom session sends operations to your backend, which calls the library and returns the results expected by the SDK callbacks.

Reuse backend instances for cached certificates, models, and keys, while keeping authentication state separate for each session. Server-side face verification must account for SDK/backend model and evidence-format compatibility and small numerical differences between platforms. Our BackendSession currently verifies faces locally and uploads the resulting evidence.

See the C/backend integration guide for operation ordering, instance lifetimes, and result ownership.

Available data and metadata

Data and metadata returned by the Session API, available for you to use in your application:

• Created — Timestamp for when the session was created
• Expires — Timestamp for when the session expires
• State — Current session state
• Reference — Your own optional reference for the session
• User IP — IP address observed when the user initiated the verification
• User agent — User agent observed when the user initiated the verification
• Given names — Given names as stated on the passport or ID
• Surname — Surname as stated on the passport or ID
• Nationality — Two-letter ISO 3166 code (e.g. “US”)
• Sex — “MALE”, “FEMALE” or “UNSPECIFIED”
• Date of birth — Formatted as YYYY-MM-DD
• Personal number — Personal number, if present in the document
• Place of birth — Place of birth, if present in the document
• Optional data — Additional personal data, if present in the document
• Optional data 2 — Additional personal data, if present in the document
• Document type — The document type (e.g. “PASSPORT”)
• Document number — Document number as stated on the passport or ID
• Expiry date — Formatted as YYYY-MM-DD
• Issuing country — Two-letter ISO 3166 code (e.g. “US”)
• Issuer — Name of the issuing authority
• Portrait image — High resolution digital image from the passport or ID, base64 encoded PNG
• Document integrity verified — Whether passive authentication verified the document data
• Active authentication — Whether active authentication was supported and verified
• Chip authentication — Whether chip authentication was supported and verified
• DSC — Document signer certificate used to verify the document
• CSCA certificate fingerprint — Fingerprint of the trusted country signing certificate authority certificate
• Face — Image of the user's face (if face verification was required), base64 encoded PNG

Session lifecycle

Possible lifecycle states for a session:

• State CREATED — The session is created
• State INITIATED — The session has been initiated by the user
• State FAILED — The session failed, e.g. because of an NFC read error
• State CANCELLED — The session was cancelled by the user
• State COMPLETED — The verification flow completed; apply your acceptance checks to the result