Open the Human Token capture natively in your iOS app using only the webAppToken of the process.
The SDK Lite is the Unico iOS SDK for the Human Token. It runs the capture in the Unico web experience embedded in the SDK and enters only with the webAppToken of a process created by your backend. The app holds no credentials: everything it needs comes from the token.
Available from iOS SDK 3.6.0 onwards, through Swift Package Manager.
How it works
Prerequisites
| Requirement | Version / value |
|---|---|
| Minimum iOS | 13 |
| Xcode | 16.0+ |
| Dependency manager | Swift Package Manager (the SDK Lite is not published on CocoaPods) |
| Required permissions | NSCameraUsageDescription |
- A backend that creates the process with Create Process and hands the
webAppTokenfrom the response to the app. - Token entry enabled for your account by Unico in the target environment.
Step 1: Install the SDK Lite
Add the package https://github.com/acesso-io/unico-check-ios and select the unicocheck-ios-spm-lite product.
- Xcode
- Package.swift
In Xcode, open File > Add Package Dependencies, enter the package URL and select the unicocheck-ios-spm-lite product.
dependencies: [
.package(url: "https://github.com/acesso-io/unico-check-ios", from: "3.6.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "unicocheck-ios-spm-lite", package: "unico-check-ios")
]
)
]
The product ships the AcessoBio module (import AcessoBio).
Step 2: Get the webAppToken from your backend
Your backend creates the process with Create Process and sends the app the webAppToken field of the response. The app passes it to the SDK as is. The token and link fields of the same response are for other uses: passed to the SDK, the token is rejected with error 73304.
- One process per journey. Create a new process, and a new token, every time the user starts the capture.
- Short-lived. The
webAppTokenis valid for 5 minutes. Create it right before opening the capture. - Same environment. The process and the SDK must use the same environment (UAT or PROD).
Never embed credentials, access keys or a fixed token in the app. The webAppToken is created by your backend for each journey.
Step 3: Open the capture
Get the webAppToken from your backend, build the SDK with AcessoBioManager, set the environment and call prepareAndOpenSelfieCamera(_:webAppToken:) with it. The call prepares the SDK and opens the capture at once.
import UIKit
import AcessoBio
final class CaptureViewController: UIViewController, AcessoBioManagerDelegate, AcessoBioSelfieDelegate {
func startCapture() {
Task {
// Your backend calls Create Process and returns the `webAppToken` field of the response
let webAppToken = try await yourBackend.createHumanTokenProcess()
let camera = AcessoBioManager(viewController: self, delegate: self)
.setEnvironment(.PROD) // Same environment used by your backend to create the process
.build()
camera?.prepareAndOpenSelfieCamera(self, webAppToken: webAppToken) // build() is imported into Swift as an optional
}
}
// Journey result. Required.
func onSuccess(_ successResult: SuccessResult) {
// Journey completed: send successResult.processId to your backend
}
// Required by the protocol. The journey result arrives in onSuccess(_:).
func onSuccessSelfie(_ result: SelfieResult) { }
func onErrorSelfie(_ errorBio: ErrorBio) {
// 73305 (expired token): create a new process and try again
}
// AcessoBioManagerDelegate
func onErrorAcessoBioManager(_ error: ErrorBio) { }
func onUserClosedCameraManually() { }
func onSystemClosedCameraTimeoutSession() { }
func onSystemChangedTypeCameraTimeoutFaceInference() { }
}
onSuccess is requiredAcessoBioSelfieDelegate declares onSuccess(_:) as optional, so the compiler does not check it. Without it, the capture does not open and onErrorSelfie receives error 74001. Copy the signature exactly as shown.
- Callbacks arrive on the main queue.
- The capture does not run on the simulator (error
73006). onSuccesssignals that the journey ended, not that the user was approved. Always read the result with Get Process or a webhook.
Environment
The capture uses the environment set by setEnvironment on the builder. Use the environment where the process was created.
Error codes
| Code | When | What to do |
|---|---|---|
73203 | The webAppToken is empty or contains only spaces | Pass the webAppToken returned by your backend |
73006 | Running on the simulator | Test on a physical device |
73302 | Authentication failed for another reason, such as network or an unexpected response | Retry; if it persists, contact support |
73303 | Unico refused to prepare the capture, including when token entry is not enabled for your account in the environment | Check with Unico that token entry is enabled in that environment |
73304 | The token was rejected (invalid signature or content), including when the token field is passed instead of the webAppToken | Pass the webAppToken of a valid process |
73305 | The token expired | Create a new process and call prepareAndOpenSelfieCamera again with the new webAppToken |
73701 | The call is not available in the SDK Lite | Use prepareAndOpenSelfieCamera(_:webAppToken:) |
74001 | The delegate does not implement onSuccess(_:) | Implement onSuccess(_:) with the exact signature |
What's next
- Fetch the result with Get Process and store
data.humanToken.valuewith the user record. - Can't use the SDK Lite? Open the journey
linkinstead, as described in iOS. - Check the versions that include the lite edition in the SDK Lite Release Notes.
- Integrating on Android? See Android SDK Lite.