Verisoul provides an iOS SDK that allows you to implement fraud prevention in your iOS applications. This guide covers the installation, configuration, and usage of the Verisoul iOS SDK.
To run the SDK a Verisoul Project ID is required. Schedule a call here to get started.
- iOS 14.0 or higher
- Xcode 15.0 or higher
- Swift 5.9 or higher
- CocoaPods 1.10+ (if using CocoaPods)
You can install VerisoulSDK in your iOS project using either CocoaPods or Swift Package Manager.
To integrate VerisoulSDK with CocoaPods:
- Ensure CocoaPods is installed on your machine. If not, run:
sudo gem install cocoapods
- Add VerisoulSDK to your Podfile:
pod 'VerisoulSDK', '~> 0.4.65'
- Run the following command to install the SDK:
pod install
- Open the
.xcworkspacefile in Xcode and start using the SDK.
To integrate VerisoulSDK using Swift Package Manager:
- Open your project in Xcode.
- Go to
File > Add Packages. - Enter the repository URL for VerisoulSDK:
https://github.com/verisoul/ios-sdk.git
- Choose the version you wish to use and add the package.
The SDK will automatically integrate into your project.
To fully utilize the Verisoul SDK, you must add the App Attest capability to your project. This capability allows the SDK to perform necessary checks and validations to ensure the integrity and security of your application.
Update your app's entitlements file:
<key>com.apple.developer.devicecheck.appattest-environment</key>
<string>production</string> <!-- Use 'development' for testing -->Call configure() when your application starts, typically in AppDelegate or the main app entry point.
import VerisoulSDK
Verisoul.shared.configure(env: .prod, projectId: "your-project-id")The configure() method initializes the Verisoul SDK with your project credentials. This method must be called once when your application starts.
Parameters:
env: The environment to use.prodfor production or.sandboxfor testingprojectId: Your unique Verisoul project identifier
The session() method returns the current session identifier after the SDK has collected sufficient device data. This session ID is required to request a risk assessment from Verisoul's API.
Important Notes:
- Session IDs are short-lived and expire after 24 hours
- The session ID becomes available once minimum data collection is complete (typically within seconds)
- You should send this session ID to your backend, which can then call Verisoul's API to get a risk assessment
Example:
do {
let sessionId = try await Verisoul.shared.session()
// Send sessionId to your backend for risk assessment
print("Session ID: \(sessionId)")
} catch {
print("Failed to retrieve session ID: \(error)")
}The reinitialize() method generates a fresh session ID and resets the SDK's data collection. This is essential for maintaining data integrity when user context changes.
Example:
// User logs out
await Verisoul.shared.reinitialize()
// Now ready for a new user to log in with a fresh sessionAfter calling this method, you can call session() to retrieve the new session identifier.
The Verisoul SDK automatically captures touch events when integrated. No additional code is required for touch event collection.
The SDK throws VerisoulException with the following error codes:
| Error Code | Description | Recommended Action |
|---|---|---|
| INVALID_ENVIRONMENT | The environment parameter passed to Verisoul.init() is invalid. Valid values are "dev", "sandbox", or "prod". |
Ensure Verisoul.init() parameter is exactly:• "dev", "sandbox", or "prod" • Case-sensitive • Free of whitespace |
| SESSION_UNAVAILABLE | A valid session ID could not be obtained. This typically occurs when Verisoul's servers are unreachable due to network blocking or a very slow connection. | • Implement exponential backoff. • Prompt user to check network or disable network blocker. • Log to identify blocking issues. |
| WEBVIEW_UNAVAILABLE | WebView is not available on the device. This can occur when WebView is disabled, missing, uninstalled, or corrupted on the device. | Prompt user to: • Enable WebView in settings • Update Android System WebView • Switch devices |
All errors are thrown as VerisoulException with the following properties:
| Property | Type | Description |
|---|---|---|
| code | String | One of the error codes above |
| message | String | Human-readable error description |
| cause | Throwable? | The underlying exception that caused the error (if any) |
For a complete working example, see the example folder in this repository.