iOS Integration Guide
iOS Inquiry SDK Integration Guide and Technical Documentation
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:
- Select your project’s Swift Packages tab
- Click on the
+
to add a package - Add the repository URL
https://github.com/persona-id/inquiry-ios-2.git
, and click Next - Choose the package options version rule you want to use. We recommend the default (up to next major version), and click Next
- 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
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:
- Go to the Persona Inquiry SDK Releases page
- Find the latest release
- Expand the
Assets
triangle and download thePersonaSDK.xcframework.zip
file - Unarchive the zip file and drag the
Persona2.xcframework
folder into your Xcode project - A dialog prompt will pop up asking to choose options for adding these files. Please ensure that
Destination
hasCopy items if needed
ticked and that it will be added to the correct target. - 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
:
- Navigate to your project's settings in Xcode and click the
Info
tab - Add a new "Privacy - Camera Usage Description" (
NSCameraUsageDescription
) entry (if not already present) to enable camera access. - Add a new "Privacy - Photo Library Usage Description" (
NSPhotoLibraryUsageDescription
) entry (if not already present) to enable photo library access. - [Optional] If using our support for video verifications, add a new "Privacy - Microphone Usage Description" (
NSMicrophoneUsageDescription
) entry (if not already present) to enable microphone access. - [Optional] If using our support for NFC verifications, "Privacy - NFC Scan Usage Description" (
NFCReaderUsageDescription
) entry (if not already present) to enable NFC access. - [required] "Privacy - Location When In Use Usage Description" (
NSLocationWhenInUseUsageDescription
) entry (if not already present) to enable GPS access. Unfortunately, Apple does not provide tools to differentiate when the API is in use. Therefore, even if your app does not utilize the GPS functionality, we must include the usage string because our SDK includes geolocation features.
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
Be sure to also update your privacy manifest according to the features you are making use of from the SDK. See our iOS Privacy Manifest instructions for more information.
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) {
// Build the inquiry with the view controller as delegate
let inquiry = Inquiry.from(templateId: "itmpl_EXAMPLE", delegate: self)
.build()
.start(from: self) // start inquiry with view controller as presenter
}
}
Implement the InquiryDelegate for Inquiry's Result
Do not rely on callbacks for critical business logic
SDK callbacks are intended for coordination between your app's UI and Persona's UI (e.g. opening and closing the flow UI). They do NOT guarantee that data are up-to-date, and cannot be reliably used to guarantee data integrity. Webhooks should be used for logic that depends on Inquiry state.
For more information, see Accessing Inquiry status and data.
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 completedinquiryCanceled
— the inquiry was cancelled by the userinquiryError
— 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 inquiry = Inquiry.from(templateId: "itmpl_EXAMPLE", delegate: delegate)
.referenceId("myUser_123")
.build()
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 inquiry = Inquiry.from(templateId: "itmpl_EXAMPLE", delegate: delegate)
.fields([
"name_first": .string("Alexander"),
"name_last": .string("Example")
])
.build()
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 inquiry = Inquiry.from(inquiryId: "inq_EXAMPLE", delegate: delegate)
.build()
If the Inquiry has already started, you will need to also pass in the session token.
let inquiry = Inquiry.from(inquiryId: "inq_EXAMPLE", delegate: delegate)
.sessionToken("ABD1234567890")
.build()
Overriding device locale
Our SDK will automatically use the language and region selected on a users device to determine localization. If your app has specific localization requirements independent of user's device settings, you can pass the localization directly to the InquiryBuilder
as follows:
let inquiry = Inquiry.from(templateId: "itmpl_EXAMPLE", delegate: delegate)
.locale("fr")
.build()
Geographical Routing
If you need to specify a geography for your network requests, you can use .routingCountry
on your InquiryTemplateBuilder
. Your data will always be stored in the region associated with your Persona account, but you will notice latency if your requests are routed to the wrong region. Our SDK will automatically pick the correct geography after the initial request but if you know your desired geo, you can request it to eliminate latency on the initial request.
let inquiry = Inquiry.fromTemplate("itmpl_EXAMPLE", delegate: delegate)
.routingCountry(RoutingCountry.de.rawValue)
.build()
Errors
In rare cases, the Persona Inquiry SDK may encounter client side errors that can not be resolved. When unrecoverable errors are encountered, the sdk will 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)
.
Customization
Make the Persona Inquiry flow look and feel like your app.
Custom Styling
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.
Custom Fonts
By default, the iOS SDK only has access to the device's system font. Font families specified in a Persona Theme must be bundled into your hosting application to be available for use by the mobile SDKs.
Custom fonts that are not available in Persona themes at all are only available to customers on Enterprise plans.
Bundling a font
For example, if you choose the font 'Rubik' in your template's Theme configuration, you will need to add a font file named Rubik.ttf
(or any compatible format) to your project by following the instructions here.
If you need to use different font weights for a given family, name each font file such that the weight is appended to the end of the family name with a -
. For example, a bold version of the Rubik
font would be named Rubik-Bold.ttf
. Valid font weight suffixes are Light
, Regular
, Medium
, Bold
, and ExtraBold
.
Government Id NFC Integration
In order to use a template that includes Government Id 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 PersonaOpenSSL library into your app using SPM or cocoapods.
- 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.
- Make sure that the entitlements file for your app includes both
TAG
andPACE
for the Near Field Communication Tag Reader Session Formats :<key>com.apple.developer.nfc.readersession.formats</key> <array> <string>TAG</string> <string>PACE</string> </array>
- 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 in the following order:A0000002471001
,A0000002472001
, and00000000000000
. - Pass in
PersonaNfcAdapter()
into the Inquiry builder for the.nfcAdapter
function. You will need to importPersonaNfc
to access this.
Video Integration
In order to enable video recording over WebRTC on iOS follow these steps:
- Include the PersonaWebRtc 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 PersonaWebRtc matches the version of the main Persona SDK that you are using.
- Link the WebRTC version 111.0.0 library into your app.
- Pass in
PersonaWebRtcAdapter()
into the Inquiry builder for the.webRtcAdapter
function. You will need to importPersonaWebRtc
to access this. - Add a
Privacy - Microphone Usage Description
to your Info.plist file.
In order to enable local video recording upload on iOS follow these steps:
- Add a
Privacy - Microphone Usage Description
to your Info.plist file.
Licenses
The Persona iOS SDK is shipped with the licenses for the 3rd party software that it uses. Be sure to include these licenses in your app as well. See here for a list of the 3rd party software that we use and their associated licenses.
Updated about 1 month ago