Client-Side iOS SDK
Learn how to integrate the client-side iOS SDK into your web 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 Unify()
function on the server. In a mobile flow, one-time password (OTP) validation is performed on the mobile phone.
In the mobile flow, once OTP validation is complete, the AuthFinishStep
function executes.
Authenticate()
The SDK requires an authToken
as a parameter for the Authenticate()
function. This token returns from the Unify()
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 possession type, and an phone number if you are using Prove’s possession check.
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 UnifyStatus()
function to validate the phone number.
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: