Client-Side iOS SDK
Learn how to integrate the client-side iOS SDK into your native new application
Installation
Prove provides the iOS SDK in Swift. It has a download size of 2.5 MB and an install size of 1.5 MB for the minimum required components. It relies on iOS native APIs. Prove’s iOS SDK supports the earlier three major versions. Prove has seen successful transactions with iOS v11.
Prove manages a repository with the libraries to enable integration.
Execute the following to import CocoaPod from the Prove pod repository:
Send the Type of Flow: Mobile
Unlike the Web SDK, when using the iOS SDK, use the mobile flow. Pass mobile to the Start()
function on the server. In a mobile flow, Mobile Auth executes first and if that fails, performs one-time password (OTP) validation on the mobile phone.
In the mobile flow, once either Mobile Auth or the OTP validation is complete, the AuthFinishStep
function executes.
In order for Mobile Auth to succeed, the customer needs to disable the VPN and Private Relay on iOS.
Authenticate()
The SDK requires an authToken
as a parameter for the Authenticate()
function. This token returns from the Start()
call of the server-side SDK. The token is session specific so it’s used for a single flow. It also expires after 15 minutes.
Retrieve authToken
To start the flow, you’ll need to send a request to your back end server with the phone number, flow type, and an optional challenge. Use either the date of birth, YYYY-MM-DD
, or the last four digits of the social security number.
Setup Authenticator
Once you have the authToken
, build the authenticator for the mobile flow.
In the event a cellular data connection is unavailable during testing, use the Builder class. It permits simulated successful session results while connected to a Wi-Fi network. Testing using a Wi-Fi connection is useful in the Sandbox environment.
Performing the Authentication
The Prove Auth object is thread safe and used as a singleton. Most Prove Auth methods are blocking and therefore can’t execute in the main application thread. The application employs an executor service with a minimum of two threads to manage threads due to the SDK’s ability to process concurrent blocking requests.
Validate the Mobile Phone
In the AuthFinishStep
, you’ll specify a function to call once the possession checks complete on the mobile phone. In the following code, you’ll notice an endpoint called /verify
. This endpoint on your back end server calls the Validate()
function to validate the phone number. If unsuccessful, the server calls the Challenge()
function and then returns the results, including customer information. Refer to the following example fields that return and then prefill on a form for the customer to verify.
OTP Configuration
You can implement two functions for the OTP handling - a start and a finish step.
To set the OTP handlers, implement OtpStartStep
and OtpFinishStep
interfaces. The Swift snippet has an example.
Retry functionality is unavailable in OTP.
OtpStartStep
example:
OtpFinishStep
example:
Verify the Customer Information
Once the customer has made any edits to their prefill information, submit that information to the back end server so the Complete()
call can then verify the customer information.