DocumentationAPI Reference
DocumentationAPI Reference

iOS SDK v2 Integration Guide

iOS Inquiry SDK v2 Integration Guide and Technical Documentation

🚧

v1 or v2?

If your Inquiry Template 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.

Requirements - Make sure the SDK is compatible

Your app needs to support iOS 11.0 or later.

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.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 PersonaInquirySDK as one of your target dependencies in your Podfile:

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

target 'Your Project' do
    pod 'PersonaInquirySDK'
end

Inquiry SDK latestInquiry 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.

Install via Carthage

Unfortunately Carthage (as of 0.37.0) does not appear to support framework binaries containing multi-architecture platforms. If you're using Carthage, you can download the pre-built XCFramework and integrate it manually using the steps outlined below.

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 Persona.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

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.

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(
    templateVersion: "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(
    templateVersion: "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"
)

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()
theme.backgroundColor = .systemPurple
theme.bodyTextColor = .white
theme.titleTextColor = .black

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