Identity Verification
getting started
mobile - client-side SDKs
iOS

Verification Flow

1. Installation

How to install Preventor iOS SDK

Requirements

The latest stable version of Xcode, since the SDK is written in Swift 5.5
Minimum target: iOS 13.0.

Install via CocoaPods

To always use the latest release, add the following to your Podfile:
1
pod 'PreventorSDK'
Copied!
Alternatively, pin to a specific version (e.g. 0.2.2):
1
pod 'PreventorSDK', '1.1.2'
Copied!
And then run:
1
pod install
Copied!

Install via Swift Package Manager

1
import PackageDescription
2
3
let package = Package(
4
name: "YourTestProject",
5
platforms: [
6
.iOS(.v13),
7
],
8
dependencies: [
9
.package(name: "PreventorSDK", url: "https://github.com/preventorid/button-ios-sdk.git", from: "0.2.2")
10
],
11
targets: [
12
.target(name: "YourTestProject", dependencies: ["PreventorSDK"])
13
]
14
)
Copied!

Adding it to an existent iOS Project via Swift Package Manager

  1. 1.
    Using Xcode go to File > Swift Packages > Add Package Dependency
  2. 3.
    Click on next and select the project target
  3. 4.
    Don't forget to set DEAD_CODE_STRIPPING = NO in your Build 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

1
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
2
cifCode: "YOUR_CIFCODE",
3
apiKey: "YOUR_API_KEY",
4
tenant: "YOUR_TENANT",
5
env: "YOUR_ENV",
6
banknu: "YOUR_BANKNU",
7
secret: "YOUR_CLIENT_SECRET")
Copied!
If the cifCode is empty or nil, a unique code is assigned.
Value
Description
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.
To initialize the SDK, you need to call the initialize(config: PSDKConfig) method:
1
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
2
cifCode: "YOUR_CIFCODE",
3
apiKey: "YOUR_API_KEY",
4
tenant: "YOUR_TENANT",
5
env: "YOUR_ENV",
6
banknu: "YOUR_BANKNU",
7
secret: "YOUR_CLIENT_SECRET")
8
PSDK.shared.initialize(config: config)
Copied!

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:
  1. 1.
    Drag a new button on your storyboard and give it your desired constraints.
  2. 2.
    Subclass the button as PreventorButton. Ensure that the module also says PreventorSDK below the class.

Add PreventorButton in your project programmatically

SwiftUI
Swift
1
import SwiftUI
2
import PreventorSDK
3
4
struct ContentView: View, PSDKDelegate {
5
6
let config: PSDKConfig
7
8
var body: some View {
9
PreventorButton()
10
}
11
12
init() {
13
self.config = PSDKConfig(flowID: "YOUR_FLOW_ID",
14
cifCode: "YOUR_CIFCODE",
15
apiKey: "YOUR_API_KEY",
16
tenant: "YOUR_TENANT",
17
env: "YOUR_ENV",
18
banknu: "YOUR_BANKNU",
19
secret: "YOUR_CLIENT_SECRET")
20
PSDK.shared.initialize(config: config)
21
}
22
}
Copied!
1
import UIKit
2
import PreventorSDK
3
4
class ViewController: UIViewController {
5
6
override func viewDidLoad() {
7
super.viewDidLoad()
8
// Add the button with dimensions
9
let button = UIPreventorButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
10
self.view.addSubview(button)
11
12
// Or Add button with autolayout support
13
let button = UIPreventorButton(frame: .zero)
14
button.translatesAutoresizingMaskIntoConstraints = false
15
self.view.addSubview(button)
16
let buttonConstraints = [
17
button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 50.0),
18
button.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -50.0),
19
button.topAnchor.constraint(lessThanOrEqualTo: self.view.topAnchor, constant: 60.0),
20
button.heightAnchor.constraint(equalToConstant: 40),
21
]
22
NSLayoutConstraint.activate(buttonConstraints)
23
}
24
25
}
Copied!

Start Verification

To start a check, just click the PreventorButton

Adjust Your App's Permissions

If you made it until here, you've successfully installed the Preventor SDK for iOS. Now let's adjust your last settings and start your first verification.
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>
1
<!-- permission strings to be include in info.plist -->
2
<key>NSCameraUsageDescription</key>
3
<string>Please give us access to your camera, to complete the verification.</string>
4
<key>NSPhotoLibraryUsageDescription</key>
5
<string>Please give us access to your photo library to verify you.</string>
6
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
7
<array>
8
<string>A0000002471001</string>
9
<string>E80704007F00070302</string>
10
<string>A000000167455349474E</string>
11
<string>A0000002480100</string>
12
<string>A0000002480200</string>
13
<string>A0000002480300</string>
14
<string>A00000045645444C2D3031</string>
15
</array>
16
<key>com.apple.developer.nfc.readersession.formats</key>
17
<array>
18
<string>TAG</string>
19
</array>
20
<key>NFCReaderUsageDescription</key>
21
<string>Give us NFC access to complete verification.</string>
Copied!
You have successfully finished setting up the Preventor iOS SDK! 🎉

4. Handling Verifications

To find out if a user started, completed, canceled or failed the verification process, you can implement the following delegate/callback methods:
Method
Description
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
SwiftUI
Swuift
1
import SwiftUI
2
import PreventorSDK
3
4
struct ContentView: View, PSDKDelegate {
5
6
let config: PSDKConfig
7
8
var body: some View {
9
PreventorButton()
10
}
11
12
init() {
13
self.config = PSDKConfig(flowID: "YOUR_FLOW_TYPE",
14
cifCode: "YOUR_CIFCODE",
15
apiKey: "YOUR_API_KEY",
16
tenant: "YOUR_TENANT",
17
env: "YOUR_ENV",
18
banknu: "YOUR_BANKNU",
19
secret: "YOUR_CLIENT_SECRET")
20
PSDK.shared.callBack(delegate: self)
21
PSDK.shared.initialize(config: config)
22
}
23
24
func onStart() {
25
print("onStart")
26
}
27
28
func onFinish() {
29
print("onFinish")
30
}
31
32
func onError(error: PSDKErrorCode) {
33
print("error:", error.rawValue)
34
}
35
36
func onSubmitted() {
37
print("onSubmitted")
38
}
39
40
}
41
Copied!
1
import UIKit
2
import PreventorSDK
3
4
class ViewController: UIViewController, PSDKDelegate {
5
6
override func viewDidLoad() {
7
super.viewDidLoad()
8
// Add the button with dimensions
9
let button = UIPreventorButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
10
self.view.addSubview(button)
11
12
// Or Add button with autolayout support
13
let button = UIPreventorButton(frame: .zero)
14
button.translatesAutoresizingMaskIntoConstraints = false
15
self.view.addSubview(button)
16
let buttonConstraints = [
17
button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 50.0),
18
button.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -50.0),
19
button.topAnchor.constraint(lessThanOrEqualTo: self.view.topAnchor, constant: 60.0),
20
button.heightAnchor.constraint(equalToConstant: 40),
21
]
22
NSLayoutConstraint.activate(buttonConstraints)
23
24
let config = PSDKConfig(flowID: "YOUR_FLOW_TYPE",
25
cifCode: "YOUR_CIFCODE",
26
apiKey: "YOUR_API_KEY",
27
tenant: "YOUR_TENANT",
28
env: "YOUR_ENV",
29
banknu: "YOUR_BANKNU",
30
secret: "YOUR_CLIENT_SECRET")
31
PSDK.shared.callBack(delegate: self)
32
PSDK.shared.initialize(config: config)
33
}
34
35
func onStart() {
36
print("onStart")
37
}
38
39
func onFinish() {
40
print("onFinish")
41
}
42
43
func onError(error: PSDKErrorCode) {
44
print("error:", error.rawValue)
45
}
46
47
func onSubmitted() {
48
print("onSubmitted")
49
}
50
51
}
Copied!