iOS SDK v1 Integration Guide

iOS Inquiry SDK Integration Guide and Technical Documentation

Looking for v2?

If your Template starts with tmpl_, you’re on v1.

We will stop making updates to v1 on December 31, 2022. You will still be able to create inquiries, but no new features or fixes will be available. We recommend moving to v2 for access to the latest product improvements- please see migration to v2 section or contact us.

Technical Documentation

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

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.

Swift 5.3

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.

swift-package-manager

Install via CocoaPods

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

ruby
1source 'https://github.com/CocoaPods/Specs.git'
2use_frameworks!
3
4target 'Your Project' do
5 pod 'PersonaInquirySDK'
6end

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.

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 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 needed ticked and that it will be added to the correct target.
  6. Click on Finish

That’s it!

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

The Persona Inquiry verification flow is initiated with an InquiryConfiguration. This configuration can be initialized with either a templateId or an inquiryId.

Please refer to the code sample below and replace my_template_id with your template ID. You can find your template ID on the Persona Dashboard’s Integration Section.

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.

swift
1class MyViewController: UIViewController {
2
3 // This is hooked up to a button which starts the flow
4 @IBAction private func buttonTapped(_ sender: UIButton) {
5 let config = InquiryConfiguration(templateId: "my_template_id")
6
7 // Create the inquiry with the view controller
8 // as the delegate and presenter.
9 Inquiry(config: config, delegate: self).start(from: self)
10 }
11}
12
13 // MARK: - Inquiry Delegate Methods
14
15extension MyViewController: InquiryDelegate {
16
17 func inquirySuccess(inquiryId: String, attributes: Attributes, relationships: Relationships) {
18 // ✅ Inquiry succeeded
19 }
20
21 func inquiryCancelled() {
22 // ⏏️ Inquiry cancelled by user
23 }
24
25 func inquiryFailed(inquiryId: String, attributes: Attributes, relationships: Relationships) {
26 // ❌ Inquiry failed
27 }
28
29 func inquiryError(_ error: Error) {
30 // ⚠️ Inquiry errored
31 }
32}

Inquiry Results

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

  • inquirySuccess — the inquiry passed
  • inquiryFailed — the inquiry failed
  • inquiryCancelled — the inquiry was cancelled by the user
  • inquiryError — the inquiry errored

Configuration Options

Some different configuration examples can be found below:

swift
1// Configuration with only a template ID
2let config = InquiryConfiguration(
3 templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre"
4)
5
6// Configuration with only a template ID in the sandbox
7let config = InquiryConfiguration(
8 templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre",
9 environment: .sandbox
10)
11
12// Configuration with a template and reference ID
13let config = InquiryConfiguration(
14 templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre",
15 referenceId: "myReference"
16)
17
18// Configuration with a template and account ID
19let config = InquiryConfiguration(
20 templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre",
21 accountId: "act_W6thEnEU19gphPqq5uTzZ4Y8"
22)
23
24// Configuration with only an inquiry ID
25let config = InquiryConfiguration(
26 inquiryId: "inq_JAZjHuAT738Q63BdgCuEJQre",
27)
28
29// Configuration with only a template ID and a theme
30var theme = InquiryTheme()
31theme.backgroundColor = .purple
32theme.bodyTextColor = .white
33
34let config = InquiryConfiguration(
35 templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre",
36 theme: theme
37)

Customization

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

Theming

You can customize visual attributes of the Persona flow by setting the desired attributes on a Theme object and passing it to InquiryConfiguration (shown in the last configuration example in the code block above).

Customizable attributes include colors, fonts, text alignments, images, and animations. A list of customizable theme attributes can be found here:https://sdk.withpersona.com/ios/docs/Structs/InquiryTheme.html

Customizing Fonts

In order to specify fonts on iOS, the fonts must be either system fonts or fonts bundled into your application. For a list of system fonts available out of the box, view: https://developer.apple.com/fonts/system-fonts/

Providing a custom font

If you would like to provide your own custom font, add a font file to the Xcode project by following the guide here: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app.

Then, you can specify your custom font in the Theme object:

swift
1/// Creates a UIFont using the embedded font
2let customFont: ((Bool, CGFloat) -> UIFont) = { bold, size in
3 let name = "CustomFontName-".appending(bold ? "Bold" : "Regular")
4
5 guard let font = UIFont(name: name, size: size) else {
6 fatalError("Could not find a font called \(name)")
7 }
8 return font
9}
10
11var theme = InquiryTheme()
12theme.titleTextFont = customFont(true, 26)
13theme.bodyTextFont = customFont(false, 18)
14theme.buttonFont = customFont(true, 18)

Replacing Strings

You can replace any title, body, or button text by providing your own strings file called Persona.strings in your app bundle. At runtime, the SDK will use any of the strings found there.

For example:

/*
Persona.strings
*/
"inquiryStartTitle" = "Verify your identity";
"inquiryStartBody" = "Let’s make sure you’re you!";
"inquiryStartButton" = "Get started";

Available String Keys

swift
1// Government ID
2"governmentIdFailedTitle" = "Couldn’t verify photos";
3"governmentIdFailedGenericReason" = "Make sure the ID details are clear to read.";
4"governmentIdFailedButton" = "Retry";
5"governmentIdStartTitle" = "Upload a photo ID";
6"governmentIdStartBody" = "We require a photo of a government ID to verify your identity.";
7"governmentIdSubmittingTitle" = "Processing ID";
8"governmentIdSubmittingBody" = "This may take a few seconds";
9"governmentIdChooseType" = "Choose 1 of the following options";
10
11// Taking Government ID photos
12"takeGovIdPhotoHint" = "Take a clear photo of the ID";
13"takeGovIdRetakePhotoButtonText" = "Retake";
14"takeGovIdReviewBackPhoto" = "Review the back of ID";
15"takeGovIdReviewFrontOrBackPhoto" = "Review the ID";
16"takeGovIdReviewFrontPhoto" = "Review the front of ID";
17"takeGovIdUsePhotoButtonText" = "Looks good";
18"takeGovIdReviewPhotoHint" = "Ensure lighting is good and lettering is clear";
19"takeGovIdBackPhotoFormat" = "Back of %@";
20"takeGovIdFrontPhotoFormat" = "Front of %@";
21"takeGovIdGuideHintBackFormat" = "Position the back of the %@ in the frame";
22"takeGovIdGuideHintFrontFormat" = "Position the front of the %@ in the frame";
23
24// Selfie
25"selfieFailedTitle" = "Something went wrong";
26"selfieFailedBody" = "Make sure your face is visible, well lit, and try again.";
27"selfieFailedButton" = "Retry";
28"selfieStartTitle" = "Take a selfie";
29"selfieStartBody" = "Let’s make sure you’re you";
30"selfieStartButton" = "Get started";
31"selfieSubmittingTitle" = "Processing selfie";
32"selfieSubmittingBody" = "This may take a few seconds";
33"takeSelfieCenterPhoto" = "Center yourself in the frame.";
34"takeSelfieLeftPhoto" = "Look slightly left.";
35"takeSelfieRightPhoto" = "Look slightly right.";
36
37// Country selection
38"countrySelectTitle" = "What country is your government ID from?";
39"countrySelectBody" = "This helps us determine the best way to verify your identity.";
40"countrySelectButton" = "Select country";
41"countrySelectPickerText" = "Country of government ID";
42
43// Country List
44"countryListAllCountries" = "ALL COUNTRIES";
45"countryListSuggested" = "SUGGESTED";
46"countryListTitle" = "Select country of ID";
47
48// Inquiry Complete
49"inquiryCompleteTitle" = "Congratulations, you’re done!";
50"inquiryCompleteBody" = "Thanks for verifying your identity.";
51"inquiryCompleteButton" = "Done";
52
53// Inquiry Failed
54"inquiryFailedTitle" = "Could not verify your identity";
55"inquiryFailedBody" = "We were unable to verify your identity.";
56"inquiryFailedButton" = "Close";
57
58// Inquiry Start
59"inquiryStartTitle" = "Verify your identity";
60"inquiryStartBody" = "Let’s make sure you’re you";
61"inquiryStartButton" = "Get started";
62
63// Database
64"databaseStartTitle" = "Just the basics";
65"databaseStartBody" = "Nothing fancy, just a few things to verify your identity.";
66"databaseStartButton" = "Continue";