iOS
This guide helps you integrate the Passbase SDK into your iOS App and start the verification flow
Please ensure that you are using the latest XCode version, since the SDK is written in Swift 5.5. As of this writing, this is Xcode 13.0. Please also install Cocoapods, if you haven't already.
Before integrating Passbase, we suggest you read first our best practice on how to integrate Passbase in your system in the overview section and complete the initial setup steps.
You can either follow the integration guide or watch the integration tutorial that shows the same steps. Please be aware that some property or function names might have slightly changed with newer versions. Make sure to compare your implementation with the latest code snippets here in the documentation.
Only customers on the Passbase Enterprise beta program should use V3 of the SDK. If you are not on the Passbase Enteprise beta program, you should use V2 of the SDK as V3 contains breaking changes.
Swift Package Manager
CocoaPods
To install the SDK, follow these steps:
- 1.In Xcode, select File > Swift Packages > Add Package Dependency and enter
https://github.com/passbase/passbase-sp.git
as the repository URL. - 2.Select a minimum version of
2.13.6
- 3.Add the Passbase product to the target of your app.
If you don't have a Podfile in your project yet, please create one. To do this, open a terminal window. Then, navigate to your iOS project's folder and run:
pod init
This will create a Podfile inside your project. Open this file and add the following code to the top of it:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/passbase/cocoapods-specs.git'
source 'https://github.com/passbase/microblink-cocoapods-specs.git'
Next, add the actual pod after the target of your app. Include also the iOS 11 requirement and
use_frameworks!
, like in the example below.# 1. Add this here
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/passbase/cocoapods-specs.git'
source 'https://github.com/passbase/microblink-cocoapods-specs.git'
# 2. Add iOS requirements
platform :ios, '11.0'
target 'YourApp' do
# 3. Add use_frameworks!
use_frameworks!
# 4. Add Passbase pod
pod 'Passbase'
end
Finally, run
pod install
to install the Passbase SDK in your project. This will create a new .xcworkspace
file inside your project's folder. Please use this file for future development, since all dependencies are installed here. If you need to update to the latest pod, use the command
pod update
inside your directory to pull the latest podspec version and get the latest version of the SDK.You have successfully installed the Passbase SDK in your iOS application! 🎉
Please use the publishable API key for all integrations. The secret key should never be exposed or used in a web integration or mobile app since it can access sensitive user data if leaked!
Open the Workspace file in your directory. This file was created through the previous step with CocoaPods. It will be called something like
YourProject.xcworkspace
.Now, open your
AppDelegate.swift
file and add import Passbase
to the top. Then add the initialize method with your publishable API key from your API settings. Your code should look now like below:import Passbase
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
PassbaseSDK.initialize(publishableApiKey: "YOUR_PUBLISBALE_API_KEY")
return true
}
}
If you made it until here, you've successfully installed the Passbase 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 Passbase 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>NSPhotoLibraryUsageDescription</key>
<string>Please give us access to your photo library to verify you.</string>
You have successfully finished setting up the Passbase iOS SDK! 🎉
To start a new verification, you can either trigger it through the storyboard or by code. This section will walk you through both.
Keep in mind that in order to successfully finish a verification, you need to pass our liveness detection. Hence, if you develop on a Simulator (e.g. iPhone Simulator via Xcode), you will only see the UI Demo Mode of our SDK. Therefore please use a real device (e.g. an attached iPhone) to fully test and develop with our SDK.
Two simple steps to get the button running:
- 1.Drag a new button on your storyboard and give it your desired constraints.
- 2.Subclass the button as
PassbaseButton
. Ensure that the module also saysPassbase
below the class.

That's it! The button should now be rendered and trigger the verification flow.
To start the verification flow programmatically, create a new button of type
PassbaseButton
. You can give it parameters, like width
, height
, x
& y
through the CGRect and add constraint to position the button.//Add to the top of the file
import Passbase
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Add the button with dimensions
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
// Or Add button with autolayout support
let button = PassbaseButton(frame: .zero)
button.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(button)
let buttonConstraints = [
button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 50.0),
button.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -50.0),
button.topAnchor.constraint(lessThanOrEqualTo: self.view.topAnchor, constant: 60.0),
button.heightAnchor.constraint(equalToConstant: 40),
]
NSLayoutConstraint.activate(buttonConstraints)
}
}
If you want to automatically prefill user's email address to skip the "Approve your Email" screen. This is available programmatically if you pass the
prefillUserEmail
parameter to the button like below. import Passbase
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Pass in the end users email to skip screen
PassbaseSDK.prefillUserEmail = "[email protected]"
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
}
}
You can automatically prefill user's country in the drop-down list. This is available programmatically if you pass the
prefillCountry
parameter to the button like below. An ISO-3166 compliant country code, case insensitive. This will not enable skipping the country selection step. import Passbase
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Pass in the end users email to skip screen
PassbaseSDK.prefillCountry = "de"
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
}
}
If you are tracking end users in your backend through an internal UUID, transaction number, stripe ID, etc., you can use the metaData object to securely pass encrypted end user information to identify completed verifications. The metadata object requires an encrypted JSON string via the private key encoded in base64.
| Value |
metaData | Encrypted JSON string via the private key encoded in base64 |
import Passbase
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Signed and Armored Metadata, which contain {internal_customer_id: "XYZ", "email": "[email protected]", "country": "de", ...}
PassbaseSDK.metaData = "AJIZZDIZJADIOAJDOIZJAOIZJDOIAJIODZJIAJDIOZJAIOZDJALANLIKESJIZZOIZDJAOIZJDOZIAJDOIAZJDAZD"
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
}
}
Encryption should be completed on the server-side. Once you have completed the encryption, please enter the encryption keys for each individual project within the developer dashboard. The metaData object is then returned on the Passbase API.

After a user completes a verification and you receive the
VERIFICATION_REVIEWED
webhook event, it is time to call the Passbase Get Identity endpoint. Using this API endpoint, you will see the new metaData object returned.If the public encryption key is not added to the developer dashboard, you will not see the metaData information returned on the API.
{
id: "1234-1234-1234-1234",
resources: [...],
metadata: { internal_customer_id: "XYZ" }
}
You have successfully started your first verification. 🎉
In some cases it's useful to know if a user has completed the verification flow or canceled it. For this, you can implement the following delegate/callback methods:
Method | Description |
onStart | This callback method is triggered once a user starts the verification flow. |
onSubmitted | |
onFinish | |
onError | This callback method is triggered if a user canceled the verification flow or the verification flow finished with an error. You can use this to find out if people dropped out of your verification flow. Error codes: CANCELLED_BY_USER
BIOMETRIC_AUTHENTICATION_FAILED |
import Passbase
import UIKit
// 1. Add PassbaseDelegate here
class ViewController: UIViewController, PassbaseDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// 2. Set the delegate object to self
PassbaseSDK.delegate = self
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
}
// 3. Implement the delegate methods
func onFinish(identityAccessKey: String) {
print("onFinish with identityAccessKey \(identityAccessKey)")
}
func onSubmitted(identityAccessKey: String) {
print("onSubmitted with identityAccessKey \(identityAccessKey)")
}
func onError(errorCode: String) {
print("onError with code \(errorCode)")
}
func onStart() {
print("onStart")
}
}
We recommend the following process for handling identity verifications:
- 1.Obtain the
identityAccessKey
of a successfully completed identity verification from the callback method and save it to your DB to the user's profile - 2.Set up webhooks to be notified once the identity verification has been processed by our system. Also once you have approved or declined the user in your dashboard
- 3.Now you can use your own backend to query the details about this identity verification with e.g. the Get Identity call to obtain the details
In order for your application to interoperate with Passbase, you should reference to your users once the Verification is completed.
For that, you will need to keep track of the identityAccessKey returned by the onFinish or onSubmitted callbacks and associate it in your backend with your end users' id. We recommend to save this key after the onSubmitted method from your user's completed verification, or listen for the incoming webhooks to make a call to the Passbase API linking back the email address of the user.
Our SDK currently supports a set of customization options which will influence the appearance. To customize the verification flow, please navigate to your developer dashboard's customization section. Here you can choose amongst a variety of colors, fonts, accepted countries & much more.

Customization Section
We also offer a dark mode, which will be automatically started if a user has activated this in his system settings.
Dark Mode
We support a variety of different languages for the verification flow. As of this writing more than 10 including (English, Spanish, German & many more). If one is missing and you want us to add support for it, please reach out to our customer support.
The SDK automatically detects the language of the user's phone settings. If we support the language, the verification flow will be set to it. Otherwise, the default is English.
The code below is a sample implementation of a class with prefilled email and button added via code. You can find a complete sample App with both approaches (Storyboard & programmatic) on our Github page.
import Passbase
import UIKit
class ViewController: UIViewController, PassbaseDelegate {
override func viewDidLoad() {
super.viewDidLoad()
PassbaseSDK.delegate = self
// Optional - You can prefill the email to skip that step.
Passbase.prefillUserEmail = "[email protected]"
let button = PassbaseButton(frame: CGRect(x: 40, y: 90, width: 300, height: 60))
self.view.addSubview(button)
}
func onFinish(identityAccessKey: String) {
print("onFinish with identityAccessKey \(identityAccessKey)")
}
func onSubmitted(identityAccessKey: String) {
print("onSubmitted with identityAccessKey \(identityAccessKey)")
}
func onError(errorCode: String) {
print("onError with code \(errorCode)")
}
func onStart() {
print("onStart")
}
}
Last modified 7mo ago