iOS
This guide provides step-by-step instructions on integrating the IDV SDK into an iOS application. It covers initialization, API configuration, workflow setup, and starting the ID verification process.
Before getting started, make sure you have installed the SDK.
Initialize
To start initialization, invoke:
import IDVSDK
IDV.shared.initialize { result in
switch result {
case .success:
print("IDV SDK initialized successfully")
case .failure(let error):
print("Initialization failed: \(error)")
}
}
Configure API Settings
Before using the SDK, configure the API connection using one of the following methods:
Username and password
let connectionConfig = CredentialsConnectionConfig(
host: "your_host",
username: "your_username",
password: "your_password"
)
IDV.shared.configure(with: connectionConfig) { result in
switch result {
case .success:
print("Configured successfully")
case .failure(let error):
print("Configuration failed: \(error)")
}
}
Token-based
let tokenConfig = TokenConnectionConfig(url: URL(string: "your_token_url")!)
IDV.shared.configure(with: tokenConfig) { result in
switch result {
case .success(let workflowIds):
print("Available workflows: \(workflowIds)")
case .failure(let error):
print("Configuration failed: \(error)")
}
}
API key
let apiKeyConfig = ApiKeyConnectionConfig(apiKey: "your_api_key")
IDV.shared.configure(with: apiKeyConfig) { result in
switch result {
case .success:
print("Configured successfully with API key")
case .failure(let error):
print("Configuration failed: \(error)")
}
}
Prepare and Start ID Verification Workflow
Retrieve available workflows
IDV.shared.getWorkflows { result in
switch result {
case .success(let workflows):
print("Available workflows: \(workflows)")
case .failure(let error):
print("Failed to fetch workflows: \(error)")
}
}
Prepare workflow
let workflowConfig = PrepareWorkflowConfig(workflowId: "your_workflow_id")
IDV.shared.prepareWorkflow(by: workflowConfig) { result in
switch result {
case .success(let workflow):
print("Workflow prepared: \(workflow.id)")
case .failure(let error):
print("Failed to prepare workflow: \(error)")
}
}
Start workflow
IDV.shared.startWorkflow(presenter: presenterViewController) { result in
switch result {
case .success(let workflowResult):
print("Verification finished. Session ID: \(workflowResult.sessionId)")
case .failure(let error):
print("Verification failed: \(error)")
}
}
Optionally, you can pass a StartWorkflowConfig with metadata:
var config = StartWorkflowConfig.default()
config.metadata = ["key": "value"]
IDV.shared.startWorkflow(presenter: self, config: config) { result in
switch result {
case .success(let workflowResult):
print("Workflow completed successfully")
case .failure(let error):
print("Workflow failed: \(error)")
}
}
To start the workflow with a specific locale:
var config = StartWorkflowConfig.default()
config.locale = "en"
IDV.shared.startWorkflow(presenter: self, config: config) { result in
switch result {
case .success(let workflowResult):
print("Workflow completed successfully")
case .failure(let error):
print("Workflow failed: \(error)")
}
}
Deinitialize SDK
When the SDK is no longer needed (for example, on logout):
IDV.shared.deinitialize { result in
switch result {
case .success:
print("SDK deinitialized")
case .failure(let error):
print("Failed to deinitialize: \(error)")
}
}
Best Practices & Troubleshooting
- Initialize the SDK first before configuring or preparing workflows
- Handle error callbacks (
Result.failure) properly - Ensure camera permissions are granted before starting workflows
- For production apps, implement secure storage for tokens and credentials