DocumentationAPI Reference
DocumentationAPI ReferenceStatus

iOS Integration Guide

iOS Inquiry SDK v2 Integration Guide and Technical Documentation

🚧

v1 or v2?

If your Template ID starts with itmpl_, you're in the right place. Otherwise, you will want to look at the v1 section. If you are interested in moving to v2, please contact [email protected]

The Persona Inquiry flow lets you securely and seamlessly collect your user's information.

Integration

Integrate the Persona Inquiry flow directly into your iOS app with our native SDK.

To integrate the Persona Inquiry SDK in your iOS app you can use Swift Package Manager, CocoaPods, or download the XCFramework for manual integration or for use with Carthage.

Installation

Install via Swift Package Manager

To install the SDK with Swift Package Manager:

  1. Select your project’s Swift Packages tab
  2. Click on the + to add a package
  3. Add the repository URL https://github.com/persona-id/inquiry-ios-2.git, and click Next
  4. Choose the package options version rule you want to use. We recommend the default (up to next major version), and click Next
  5. Check that the package is being added to the right target and click Finish.

Install via CocoaPods

To install the SDK with CocoaPods, add PersonaInquirySDK2 as one of your target dependencies in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'Your Project' do
    pod 'PersonaInquirySDK2'
end

Inquiry SDK latest

Please be sure to run pod update and use pod install --repo-update to ensure you have the most recent version of the SDK installed.

Manual installation

The SDK is released as an XCFramework which makes manually installing the SDK a straightforward process:

  1. Go to the Persona Inquiry SDK Releases page
  2. Find the latest release
  3. Expand the Assets triangle and download the PersonaSDK.xcframework.zip file
  4. Unarchive the zip file and drag the Persona2.xcframework folder into your Xcode project
  5. A dialog prompt will pop up asking to choose options for adding these files. Please ensure that Destination has Copy items if neededticked and that it will be added to the correct target.
  6. Click on Finish

Minimum deployment target

The SDK requires a minimum deployment target of iOS 13.0 or later. Ensure your app's minimum deployment is at least 13.0.

Update your Info.plist

In addition to importing the dependency, you also need to modify your Info.plist:

  1. Navigate to your project's settings in Xcode and click the Info tab
  2. Add a new "Privacy - Camera Usage Description" (NSCameraUsageDescription) entry (if not already present) to enable camera access.
  3. Add a new "Privacy - Photo Library Usage Description" (NSPhotoLibraryUsageDescription) entry (if not already present) to enable photo library access.

Privacy Configuration

This SDK collects a user’s IDFV for fraud prevention purposes. In App Store Connect > Your App > App Privacy, if you haven’t already add in a “Device Identifier,” and fill out the questionnaire with the following answers:

  • Usage: App Functionality (covers fraud prevention)
  • Are the device IDs collected from this app linked to the user’s identity? Yes
  • Do you or your third-party partners use device IDs for tracking purposes? No

Usage

Build and Launch the Inquiry

The Persona Inquiry verification flow is initiated with an InquiryConfiguration. This configuration can be initialized with either Inquiry Template ID, Inquiry Template Version, or Inquiry ID. The other parameters are optional: theme, referenceId, accountId, and environment (which defaults to .production).

Please refer to the code sample below and replace TEMPLATE_ID with your template ID. You can find your template ID on the Persona Dashboard under "Integration".

This starts the Inquiry flow and takes control of the user interface. Once the flow completes the control of the user interface is returned to the app and the appropriate delegate method will be called.

class MyViewController: UIViewController {

    // This is hooked up to a button which starts the flow
    @IBAction private func buttonTapped(_ sender: UIButton) {
        let config = InquiryConfiguration(templateId: "TEMPLATE_ID")

        // Create the inquiry with the view controller
        // as the delegate and presenter.
        Inquiry(config: config, delegate: self).start(from: self)
    }
}

Implement the InquiryDelegate for Inquiry's Result

In order to receive the inquiry result, please implement the InquiryDelegate protocol. For example:

extension MyViewController: InquiryDelegate {

    func inquiryComplete(inquiryId: String, status: String, fields: [String : InquiryField]) {
        // Inquiry completed
    }
    
    func inquiryCanceled(inquiryId: String?, sessionToken: String?) {
        // Inquiry cancelled by user
    }
    
    func inquiryError(_ error: Error) {
        // Inquiry errored
    }
}

Inquiry Results

The results of the inquiry are passed back to the InquiryDelegate, and are as follows

  • inquiryComplete — the inquiry completed
  • inquiryCanceled — the inquiry was cancelled by the user
  • inquiryError — the inquiry errored

Linking an Inquiry to your Users

To make it easier to find Inquiries in the Persona Dashboard, we recommend passing in your system's user ID for the Inquiry reference ID.

let config = InquiryConfiguration(
    templateId: "TEMPLATE_ID",
    referenceId: "myUser_123"
)

Pre-writing to the Inquiry

If you want to add extra information to the Inquiry before the user even starts, you can pass them in as fields.

let config = InquiryConfiguration(
    templateId: "TEMPLATE_ID",
    fields: [
        "name_first": .string("Susan"),
        "name_last": .string("Realman")
    ]
)

Starting/Resuming an Inquiry from ID

When you create an Inquiry on the server, you can pass the Inquiry ID instead of the Template ID.

let config = InquiryConfiguration(
    inquiryId: "inq_123456"
)

If the Inquiry has already started, you will need to also pass in the session token.

let config = InquiryConfiguration(
    inquiryId: "inq_123456",
    sessionToken: "ABD1234567890"
)

Errors

It is rare but, the Persona Inquiry Sdk may encounter client side errors that can not be resolved. When unrecoverable errors are encountered, the Persona Inquiry Sdk will log the error to the Inquiry Session and then immediately callback to the main application with a debug description of the error.

The most common reasons the Persona Inquiry Sdk will error include unrecoverable networking errors, misconfigured templates (should only be encountered during development), or failing to establish a connection the the device camera.

The error callback is located on the InquiryDelegate with the following signature: func inquiryError(_ error: Error).

This error object is of public type PersonaError defined below.

/// Errors that can occur clientside during the inquiry flow which result in the inquiryError callback
public enum PersonaError: Error, CustomDebugStringConvertible {
    /// An api error or connectivity error occurred
    case networking
    /// Failed to get a context to the device camera
    case camera
    /// Permissions have been denied or incorrectly configured
    case permissions
    /// The corresponding template is misconfigured
    case misconfigured(InquiryConfigurationError)
    /// An otherwise unexpected or unhandled error occurred
    case other

    /// A short debug description for why the persona sdk errored
    public var debugDescription: String {
        switch self {
        case .networking:
            return "There was a problem reaching the server."
        case .misconfigured(let error):
            return error.errorDescription ?? "There was a problem with the template configuration."
        case .camera:
            return "There was a problem establishing a connection to the camera."
        case .permissions:
            return "Permissions have been denied or incorrectly configured."
        case .other:
            return "An otherwise unexpected error occurred."
        }
    }
}

Configuration errors are described below, this category of errors should only be encountered during development.

/// Client side InquiryConfiguration errors
public enum InquiryConfigurationError: Error {
    /// Inquiry Template Id does not match known structure
    case invalidTemplateId(String)
    /// Inquiry Template Version does not match known structure
    case invalidTemplateVersion(String)
    /// This version of the SDK does not support Inquiry Template Ids with supplied prefix
    case prefixSDKVersionMismatch(String)
    /// The template configuration from server was not valid
    case serverConfiguration
}

extension InquiryConfigurationError: LocalizedError {
    public var errorDescription: String? {
        switch self {
        case .invalidTemplateId(let templateId):
            return "Could not start Inquiry for templateId: \(templateId). Does not match Inquiry Template Id structure."
        case .invalidTemplateVersion(let templateVersion):
            return "Could not start Inquiry for templateVersion: \(templateVersion). Does not match Inquiry Template Version structure."
        case .prefixSDKVersionMismatch(let prefix):
            return "Inquiry Template Ids with prefix: \(prefix) are only valid in v1.x.x of SDK."
        case .serverConfiguration:
            return "There was a problem with the template configuration on the server."
        }
    }
}

Technical Documentation

If you want to dive right in to the API documentation, you can do so here.

Customization

Make the Persona Inquiry flow look and feel like your app.

Custom Styling

Set your own colors, buttons, fonts and more. First, make an InquiryTheme object and pass it in to the InquiryConfiguration. For example:

// Configuration with only a template ID and a theme
var theme = InquiryTheme(themeSource: .server)

let config = InquiryConfiguration(
   templateId: "TEMPLATE_ID",
   theme: theme
)

You can configure the styles that are applied to the inquiry template in the Persona Dashboard. For more information on using the theme editor, see our help article.

🚧

If you are currently using the InquiryTheme() constructor that takes no arguments to initalize your theme, note that this is now deprecated. Please see our guide for migrating from client side theming to server side theming via the Persona dashboard.

There are some properties that are not supported yet, and others that cannot be applied without component-level theming (e.g. custom assets and visuals). If you run into gaps that block your migration, please reach out.

Custom Fonts

The iOS SDK will use the font name set in the Persona Dashboard for various text fields. Note that the font must be bundled in the hosting application in order to be loaded at runtime.

Passport Nfc Integration

In order to use a template that includes passport nfc reading capabilities on iOS, follow these steps:

  • Include the PersonaNfc project in your app via SPM or cocoapods. You can include this in the same way you would the main Persona SDK. Make sure that the version of PersonaNfc matches the version of the main Persona SDK that you are using.
  • Link the OpenSSL (version 1.1.190 or 1.1.180 if using cocoapods) library into your app as well.
  • Add the NFC capability to your app (target → signing & capabilities → + Capability → Near Field Communication Tag Reading). You will also need to add the NFC capability to the Identifier for the app in the Apple Developer portal.
  • Add a Privacy - NFC Scan Usage Description to your info.plist file, along with a description.
  • Add a ISO7816 application identifiers for NFC Tag Reader Session to your info.plist file with these values: 00000000000000, A0000002472001 and A0000002471001.
  • Pass in PersonaNfcAdapter() into the InquiryConfiguration for nfcAdapter. You will need to import PersonaNfc to access this.