Integration
Swift Package Manager
- File > Add Package Dependencies
- Add https://github.com/microblink/microblink-platform-ios.git
- Select Exact Version and add the latest released version.
- Add both
MicroblinkPlatformandMicroblinkPlatformEngineto your target.
Scanner dependencies
The SDK uses Microblink's scanning SDKs for documents, cards, and faces. Add them to your app, even if you build your own screens:
BlinkIDVerifyUXfromhttps://github.com/microblink/blinkid-verify-ios, Exact Version 4000.0.3.BlinkCardUXfromhttps://github.com/microblink/blinkcard-ios, Exact Version 3001.0.2.- For workflows with a face step:
BiometricsSDK.xcframeworkandBiometricsEngine.xcframework, linked and embedded. Without them, a face step fails.
Camera permission
Add NSCameraUsageDescription to your app's Info.plist, with an explanation of why your app needs the camera, for example to capture documents and selfies.
The SDK consists of two frameworks:
MicroblinkPlatform: our verification screens, which most integrations use.MicroblinkPlatformEngine: the core library, which runs the verification session, and provides the configuration and result types.
You import both, even if you only use our screens. To build your own screens on the core library alone, read Platform SDK architecture.
Start a verification
When the user starts a verification, get a new sdkConfiguration from your backend, and create the configuration:
import MicroblinkPlatform
import MicroblinkPlatformEngine
let configuration = EngineConfiguration(
service: ServiceSettings(sdkConfiguration: sdkConfiguration)
)
Then pass it to MicroblinkPlatform.view(configuration:onEvent:), which returns a SwiftUI view.
The view runs the steps of the workflow, and reports what happens to your onEvent closure.
Present it full screen, and dismiss it when you receive .finished or .canceled.
Customize the screens through MicroblinkPlatformTheme.shared before you create the view.
Both the theme and MicroblinkPlatform.view(configuration:onEvent:) are isolated to the main actor.
SwiftUI
import MicroblinkPlatform
import MicroblinkPlatformEngine
import SwiftUI
struct ContentView: View {
let sdkConfiguration: String
@State private var showSDK = false
var body: some View {
Button("Start SDK") {
showSDK = true
}
.fullScreenCover(isPresented: $showSDK) {
MicroblinkPlatform.view(
configuration: EngineConfiguration(
service: ServiceSettings(sdkConfiguration: sdkConfiguration)
)
) { event in
switch event {
case .finished, .canceled:
showSDK = false
case .cardScanned:
// The verification continues; don't dismiss.
break
@unknown default:
showSDK = false
}
}
}
}
}
UIKit
In a UIKit app, wrap the view in a UIHostingController:
import MicroblinkPlatform
import MicroblinkPlatformEngine
import SwiftUI
import UIKit
class ViewController: UIViewController {
func startVerification(sdkConfiguration: String) {
let configuration = EngineConfiguration(
service: ServiceSettings(sdkConfiguration: sdkConfiguration)
)
let hostingController = UIHostingController(
rootView: MicroblinkPlatform.view(configuration: configuration) { [weak self] event in
switch event {
case .finished(let result):
print("Outcome:", result.outcome)
self?.dismiss(animated: true)
case .canceled(let cancelState):
print("User exited:", cancelState.reason)
self?.dismiss(animated: true)
case .cardScanned:
// The verification continues; don't dismiss.
break
@unknown default:
self?.dismiss(animated: true)
}
}
)
hostingController.modalPresentationStyle = .fullScreen
present(hostingController, animated: true)
}
}
See Configuration for what each event contains.