iOS
1. Installation
How to install Preventor iOS SDK
Requirements
The latest stable version of Xcode, since the SDK is written in Swift 5.7.1
Minimum target: iOS 13.0.
Install via CocoaPods
To always use the latest release, add the following to your Podfile:
pod 'PreventorSDK'
Alternatively, pin to a specific version (e.g. 0.2.2):
pod 'PreventorSDK', '2.1.0'
And then run:
pod install
Install via Swift Package Manager
import PackageDescription
let package = Package(
name: "YourTestProject",
platforms: [
.iOS(.v13),
],
dependencies: [
.package(name: "PreventorSDK", url: "https://github.com/preventorid/button-ios-sdk.git", from: "2.1.0)
],
targets: [
.target(name: "YourTestProject", dependencies: ["PreventorSDK"])
]
)
Adding it to an existent iOS Project via Swift Package Manager
Using Xcode go to File > Swift Packages > Add Package Dependency
Paste the project URL: https://github.com/preventorid/button-ios-sdk.git
Click on next and select the project target
Don't forget to set
DEAD_CODE_STRIPPING = NO
in yourBuild Settings
(https://bugs.swift.org/plugins/servlet/mobile#issue/SR-11564)
2. Initialize SDK
For integration, you need to configure the pre-padding shown below. You must first implement the PSDKConfig
structure.
Credential prefill
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
cifCode: "YOUR_CIFCODE",
apiKey: "YOUR_API_KEY",
tenant: "YOUR_TENANT",
env: "YOUR_ENV",
banknu: "YOUR_BANKNU",
secret: "YOUR_CLIENT_SECRET",
invitation: "YOUR_INVITATION_ID",
broker: "YOUR_BROKER")
YOUR_FLOW_ID
Defines the biometric process
UNIQUE_CUSTOMER_CODE
Is the unique customer profile code.
YOUR_API_KEY
Your provided apikey.
YOUR_CLIENT_SECRET
Your provided clientsecret.
YOUR_TENANT
Your provided tenant.
YOUR_BANKNU
Your provided banknu.
YOUR_ENV
Your provided env.
YOUR_INVITATION_ID
Your invitation ID
YOUR_BROKER
Your broker
To initialize the SDK, you need to call the initialize(config: PSDKConfig) method:
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
cifCode: "YOUR_CIFCODE",
apiKey: "YOUR_API_KEY",
tenant: "YOUR_TENANT",
env: "YOUR_ENV",
banknu: "YOUR_BANKNU",
secret: "YOUR_CLIENT_SECRET",
invitation: "YOUR_INVITATION_ID",
broker: "YOUR_BROKER")
PSDK.shared.initialize(config: config)
3. Start the Verification
To start a new verification, you first need to create the PreventorButton
Add Button via Storyboard
Two simple steps to get the button running:
Drag a new button on your storyboard and give it your desired constraints.
Subclass the button as
PreventorButton
. Ensure that the module also saysPreventorSDK
below the class.

Add PreventorButton in your project programmatically
import SwiftUI
import PreventorSDK
struct ContentView: View {
@ObservedObject var store: ContentViewModel
let config: PSDKConfig
var body: some View {
PreventorButton()
}
init() {
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
cifCode: "YOUR_CIFCODE",
apiKey: "YOUR_API_KEY",
tenant: "YOUR_TENANT",
env: "YOUR_ENV",
banknu: "YOUR_BANKNU",
secret: "YOUR_CLIENT_SECRET",
invitation: "YOUR_INVITATION_ID",
broker: "YOUR_BROKER")
PSDK.shared.initialize(config: config) { isSuccessful in
//your code
}
}
}
class ContentViewModel: ObservableObject, PSDKDelegate {
//YOUR IMPLEMENTATION
func updatePreventorSDKDelegate() {
PSDK.shared.delegate = self
}
func onStart() {
print("onStart")
}
func onFinish(result: PSDKResult) {
print("onFinish")
}
func onError(error: PSDKErrorCode) {
print("error:", error.rawValue)
}
func onSubmitted(result: PSDKResult) {
print("onSubmitted")
}
}
Start Verification
To start a check, just click the PreventorButton
Adjust Your App's Permissions

Please add the following permissions to your app's Info.plist
, so that the Preventor iOS SDK can access a user's camera to run a verification. You can do this in the property list view or by code.
Right-click somewhere outside the table and select Add Row
. Now add the entries like below.
Or if you prefer to do this step with code, right-click on Info.plist
and select Open As -> Source Code. Add the lines below somewhere inside the <dict> </dict>
<!-- permission strings to be include in info.plist -->
<key>NSCameraUsageDescription</key>
<string>Please give us access to your camera, to complete the verification.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Please give us access to your location to complete the verification.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Please give us access to your location to complete the verification.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Please give us access to your photo library to verify you.</string>
<key>NFCReaderUsageDescription</key>
<string>Give us NFC access to complete verification.</string>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>TAG</string>
</array>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>E80704007F00070302</string>
<string>A000000167455349474E</string>
<string>A0000002480100</string>
<string>A0000002480200</string>
<string>A0000002480300</string>
<string>A00000045645444C2D3031</string>
</array>
You have successfully finished setting up the Preventor
iOS SDK! 🎉
Customization
If you want to add your own customization you can use the following methods
setNavigationTitle
Use this method to change the navigation title of the SDK.
4. Handling Verifications
To find out if a user started, completed, canceled or failed the verification process, you can implement the following delegate methods:
onStart
This callback method is triggered once a user starts the verification flow.
onSubmitted
Method that is being called once verification data is submitted to Preventor.
onFinish
Method that is being called once a user clicks the "Finish" button.
onError
This callback method fires when a user canceled the verification flow, the verification ended with an error, or the user performed an incorrect process. You can use this to find out the reason for the error.
Error codes:
CANCELLED_BY_USER
BIOMETRIC_AUTHENTICATION_FAILED
BAD_STEP_BY_USER MISSING_PARAMETERS
onNextStep
This callback method is called when the SDK is ready to move on to the next check.
import SwiftUI
import PreventorSDK
struct ContentView: View {
@ObservedObject var store: ContentViewModel
let config: PSDKConfig
var body: some View {
PreventorButton()
}
init() {
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
cifCode: "YOUR_CIFCODE",
apiKey: "YOUR_API_KEY",
tenant: "YOUR_TENANT",
env: "YOUR_ENV",
banknu: "YOUR_BANKNU",
secret: "YOUR_CLIENT_SECRET",
invitation: "YOUR_INVITATION_ID",
broker: "YOUR_BROKER")
PSDK.shared.initialize(config: config) { isSuccessful in
//your code
}
}
}
class ContentViewModel: ObservableObject, PSDKDelegate {
//YOUR IMPLEMENTATION
func updatePreventorSDKDelegate() {
PSDK.shared.delegate = self
}
func onStart() {
print("onStart")
}
func onFinish(result: PSDKResult) {
print("onFinish")
}
func onError(error: PSDKErrorCode) {
print("error:", error.rawValue)
}
func onSubmitted(result: PSDKResult) {
print("onSubmitted")
}
}
Last updated
Was this helpful?