iOS Core SDK¶
Overview¶
The Core SDK is the foundation module of the Biometrid SDK. It handles SDK initialization, process management, step navigation, flow retrieval, and real-time socket communication. All other Biometrid modules require Core SDK to be initialized first.
Prerequisites¶
- iOS 16.0 or higher
- A valid Biometrid
url,appidentifier andcredential - CocoaPods 1.13 or higher
- Access to the Biometrid Cloudsmith cocoapods sources
Installation¶
Add the Biometrid CocoaPods sources and the BiometridStandard pod to your Podfile:
source 'https://dl.cloudsmith.io/public/biometrid/mobile/cocoapods/index.git'
source 'https://dl.cloudsmith.io/public/biometrid/face01-liveness/cocoapods/index.git'
source 'https://cdn.cocoapods.org/'
platform :ios, '16.0'
target 'YourApp' do
use_frameworks!
pod 'BiometridStandard', '3.2.0'
end
Then run:
pod install
pod 'BiometridStandard', '3.2.0'
Initialization¶
The Core SDK is accessed through the BiometridStandard singleton object. Initialize the SDK by providing a callback that contains your credentials and handles success/failure events.
import BiometridStandard
class MyInitCallback: BiometridStandardInitCallback {
var url: String = "https://api.biometrid.com"
var app: String = "your-application-uuid"
var credential: String = "your-credential-uuid"
var language: Language = .english
var customHeaders: [AnyHashable: Any]? = nil
func initializationSuccess() {
// SDK initialized successfully
}
func initializationFailure(error: BiometridErrorInfo) {
// Handle initialization error
let errorCode = error.code
let errorMessage = error.message
}
}
let initCallback = MyInitCallback()
Task {
try await BiometridStandard.shared.initialize(initCallback: initCallback)
}
Available Methods¶
initialize¶
func initialize(initCallback: BiometridStandardInitCallback) async
Initializes the SDK with the provided credentials and configuration. Must be called before any other SDK operation.
| Parameter | Type | Description |
|---|---|---|
initCallback |
BiometridStandardInitCallback |
Callback containing credentials and event handlers |
set¶
func set(callback: BiometridStandardProcessCallback)
Sets the process callback to receive results from process operations (create, step navigation, flow retrieval, socket events).
| Parameter | Type | Description |
|---|---|---|
callback |
BiometridStandardProcessCallback |
Callback to receive process operation results |
createProcess¶
func createProcess() async
Creates a new verification process. Results are delivered through the BiometridStandardProcessCallback.
getCurrentStep¶
func getCurrentStep(processId: String) async
Retrieves the current step of a process.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The identifier of the process |
previousStep¶
func previousStep(processId: String) async
Navigates to the previous step in the process flow.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The identifier of the process |
updateStep¶
func updateStep(processId: String, data: [String: Any]?, includeResponseData: Bool) async
Submits data for the current step and advances the process.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The identifier of the process |
data |
[String: Any]? |
Key-value data to submit for the current step |
includeResponseData |
Bool |
If true, appends response=data query to receive data in the response |
updateStepMultipart¶
func updateStepMultipart(processId: String, formBuilder: MultipartFormDataBuilder, includeResponseData: Bool) async
Submits step data as multipart form data. Use this method when you need to upload files or binary data as part of a step update.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The identifier of the process |
formBuilder |
MultipartFormDataBuilder |
Builder to construct multipart form data |
includeResponseData |
Bool |
If true, appends response=data query to receive data in the response |
getFlow¶
func getFlow() async
Retrieves the complete flow definition including all steps and their configurations.
getCustomization¶
func getCustomization() -> Customization?
Returns the customization settings received during initialization (colors, icons, typography, images, translations).
setRelateProcessId¶
func setRelateProcessId(processId: String)
Associates a related process ID for cross-process references.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The related process identifier |
connectSocket¶
func connectSocket(processId: String)
Establishes a real-time socket connection for the given process. Socket events are delivered through the socketEvent method of BiometridStandardProcessCallback.
| Parameter | Type | Description |
|---|---|---|
processId |
String |
The process identifier to connect the socket for |
Callback Interfaces¶
BiometridStandardInitCallback¶
protocol BiometridStandardInitCallback {
var url: String { get }
var app: String { get }
var credential: String { get }
var language: Language { get }
var customHeaders: [AnyHashable: Any]? { get }
func initializationSuccess()
func initializationFailure(error: BiometridErrorInfo)
}
| Property/Method | Type | Description |
|---|---|---|
url |
String |
Base URL for the Biometrid API |
app |
String |
Application identifier |
credential |
String |
Authentication credential |
language |
Language |
SDK language setting |
customHeaders |
[AnyHashable: Any]? |
Optional custom HTTP headers |
initializationSuccess() |
Function | Called when initialization succeeds |
initializationFailure(error:) |
Function | Called when initialization fails |
BiometridStandardProcessCallback¶
protocol BiometridStandardProcessCallback {
func createProcessSuccess(processId: String?)
func createProcessFailure(error: BiometridErrorInfo)
func getCurrentStepSuccess(response: StepResponse)
func getCurrentStepFailure(error: BiometridErrorInfo)
func previousStepSuccess(response: StepResponse)
func previousStepFailure(error: BiometridErrorInfo)
func updateStepSuccess(response: StepResponse)
func updateStepFailure(error: BiometridErrorInfo)
func updateStepMultipartSuccess(response: StepResponse)
func updateStepMultipartFailure(error: BiometridErrorInfo)
func getFlowSuccess(response: GetFlowResponse)
func getFlowFailure(error: BiometridErrorInfo)
func socketEvent(event: String, response: Any?)
}
| Method | Description |
|---|---|
createProcessSuccess(processId:) |
Process created successfully, returns the process ID |
createProcessFailure(error:) |
Process creation failed |
getCurrentStepSuccess(response:) |
Current step retrieved successfully |
getCurrentStepFailure(error:) |
Failed to retrieve current step |
previousStepSuccess(response:) |
Navigated to previous step successfully |
previousStepFailure(error:) |
Failed to navigate to previous step |
updateStepSuccess(response:) |
Step updated successfully |
updateStepFailure(error:) |
Failed to update step |
updateStepMultipartSuccess(response:) |
Multipart step updated successfully |
updateStepMultipartFailure(error:) |
Failed to update multipart step |
getFlowSuccess(response:) |
Flow retrieved successfully |
getFlowFailure(error:) |
Failed to retrieve flow |
socketEvent(event:response:) |
Real-time socket event received |
Data Models¶
BiometridErrorInfo¶
class BiometridErrorInfo {
var code: String?
var message: String?
var data: Any?
}
StepResponse¶
class StepResponse {
var data: StepResponseData?
var meta: Meta?
var status: Bool?
}
class StepResponseData {
var processID: String?
var flowID: String?
var step: Step?
var path: [Path]?
var completedSteps: [Any]?
}
class Step {
var id: String?
var name: String?
var action: StepResponseAction?
var settings: StepResponseSettings?
}
class StepResponseAction {
var type: String?
var channel: String?
var fields: [Field]?
var provider: Provider?
var settings: StepResponseActionSettings?
var attributes: StepResponseActionAttributes?
}
GetFlowResponse¶
class GetFlowResponse {
var data: GetFlowData?
var meta: Meta?
var status: Bool?
}
class GetFlowData {
var id: String?
var name: String?
var steps: [GetFlowStep]?
}
Customization¶
class Customization {
var colors: Colors?
var icons: Icons?
var typography: Typography?
var images: Images?
var translations: Translations?
var settings: Settings?
}
Enums¶
Language¶
| Case | Raw Value |
|---|---|
english |
"en-GB" |
portuguese |
"pt-PT" |
french |
"fr-FR" |
spanish |
"es-ES" |
italian |
"it-IT" |
Error Handling¶
Errors are returned as BiometridErrorInfo objects with the following properties:
code- Error code string prefixed withMSC(e.g.,MSCprefix indicates a Core module error)message- Human-readable error descriptiondata- Optional additional error data
Usage Example¶
import BiometridStandard
class BiometridManager: BiometridStandardInitCallback, BiometridStandardProcessCallback {
// MARK: - Init Callback Properties
var url: String = "https://api.biometrid.com"
var app: String = "my-application-uuid"
var credential: String = "my-credential-uuid"
var language: Language = .english
var customHeaders: [AnyHashable: Any]? = nil
func startSDK() {
Task {
try await BiometridStandard.shared.initialize(initCallback: self)
}
}
// MARK: - Init Callbacks
func initializationSuccess() {
BiometridStandard.shared.set(callback: self)
Task {
try await BiometridStandard.shared.createProcess()
}
}
func initializationFailure(error: BiometridErrorInfo) {
print("Init failed: \(error.message ?? "")")
}
// MARK: - Process Callbacks
func createProcessSuccess(processId: String?) {
guard let processId = processId else { return }
Task {
try await BiometridStandard.shared.getCurrentStep(processId: processId)
}
}
func createProcessFailure(error: BiometridErrorInfo) {
print("Create process failed: \(error.message ?? "")")
}
func getCurrentStepSuccess(response: StepResponse) {
let step = response.data?.step
// Handle the current step based on step?.action?.type
}
func getCurrentStepFailure(error: BiometridErrorInfo) {
print("Get step failed: \(error.message ?? "")")
}
func previousStepSuccess(response: StepResponse) { }
func previousStepFailure(error: BiometridErrorInfo) { }
func updateStepSuccess(response: StepResponse) { }
func updateStepFailure(error: BiometridErrorInfo) { }
func getFlowSuccess(response: GetFlowResponse) { }
func getFlowFailure(error: BiometridErrorInfo) { }
func socketEvent(event: String, response: Any?) {
// Handle real-time events
}
}