Migrate to v2
This guide lists the changes you need to make in your iOS app to move from v1 to v2 of the iOS SDK.
The SDK no longer creates transactions: your backend does, and passes the result to your app. Before you update the SDK, update your backend as described in the Platform migration guide, in particular No proxy and Consent.
Installation
The package is unchanged: MicroblinkPlatform, from https://github.com/microblink/microblink-platform-ios.git.
In Xcode, change its dependency rule to Exact Version 2.0.0.
V2 consists of two frameworks:
MicroblinkPlatform: our screens, which most integrations use.MicroblinkPlatformEngine: the core library, which also provides the configuration and result types.
You import both, even if you only use our screens.
V2 also needs the scanning SDKs:
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.
Remove the old IDLiveFaceCamera, IDLiveFaceDetection, and IDLiveFaceIAD dependencies.
Keep NSCameraUsageDescription in your app's Info.plist.
The minimum iOS version is now iOS 17.0, up from iOS 16.0.
Update your workflows to v2 before you create transactions for v2 of the SDK.
The SDK doesn't start a transaction whose workflow has an older major or minor version than the SDK.
Our screens show an error instead, and closing it sends .canceled with the reason .unsupportedWorkflowVersion.
Starting a verification
MicroblinkPlatformSDK and MicroblinkPlatformSDKDelegate are removed.
Instead, MicroblinkPlatform.view(configuration:onEvent:) returns a SwiftUI view, and reports what happens through a single closure.
Instead of a workflow ID, proxy URL, and consent, you pass the sdkConfiguration your backend got when it created the transaction.
As in v1, you present the SDK, and you dismiss it when it's done.
In a UIKit app, wrap the view in a UIHostingController:
- v1
- v2
let serviceSettings = MicroblinkPlatformServiceSettings(
workflowId: "ID of the workflow to use",
url: "URL of your proxy service",
consent: MicroblinkPlatformConsent(
userId: "unique user ID",
isProcessingStoringAllowed: true,
isTrainingAllowed: true,
isGivenOn: .now
)
)
let sdk = MicroblinkPlatformSDK(
serviceSettings: serviceSettings,
delegate: self
)
present(sdk.startSDK(), animated: true)
// MicroblinkPlatformSDKDelegate
func microblinkPlatformSDKDidFinish(
viewController: UIViewController,
result: MicroblinkPlatformResult
) {
print("Transaction ID:", result.transactionId)
print("Transaction status:", result.status)
viewController.dismiss(animated: true)
}
func microblinkPlatformSDKDidClose(
viewController: UIViewController,
cancelState: MicroblinkPlatformCancelState
) {
print("User exited:", cancelState.cancelReason)
viewController.dismiss(animated: true)
}
// sdkConfiguration is the value your backend got from POST /api/v2/transaction.
let configuration = EngineConfiguration(
service: ServiceSettings(sdkConfiguration: sdkConfiguration)
)
weak var presentedController: UIViewController?
let verificationView = MicroblinkPlatform.view(configuration: configuration) { event in
switch event {
case .finished(let result):
print("Transaction ID:", result.transactionId ?? "none")
print("Outcome:", result.outcome)
case .canceled(let cancelState):
print("User exited:", cancelState.reason)
case .cardScanned:
// The verification continues; don't dismiss.
return
@unknown default:
break
}
presentedController?.dismiss(animated: true)
}
let hostingController = UIHostingController(rootView: verificationView)
hostingController.modalPresentationStyle = .fullScreen
presentedController = hostingController
present(hostingController, animated: true)
In a SwiftUI app, present the view directly, for example with .fullScreenCover, and set the presentation state to false when you receive .finished or .canceled.
Configuration fields
The configuration only covers the connection to the Platform.
As in v1, you customize our screens separately, through MicroblinkPlatformTheme.shared (see Customization).
- v1
- v2
let serviceSettings = MicroblinkPlatformServiceSettings(
workflowId: "...",
url: "...",
consent: MicroblinkPlatformConsent(
userId: "...",
isProcessingStoringAllowed: true,
isTrainingAllowed: false,
isGivenOn: .now
),
additionalRequestHeaders: [:],
correlationId: nil
)
serviceSettings.getWorkflowInfo = "..."
serviceSettings.startTransaction = "..."
serviceSettings.cancelWorkflow = "..."
let configuration = EngineConfiguration(
service: ServiceSettings(
sdkConfiguration: "...",
retryPolicy: NetworkRetryPolicy()
)
)
MicroblinkPlatformServiceSettings is replaced by EngineConfiguration(service: ServiceSettings(sdkConfiguration:)).
Here's what happened to each of its fields:
workflowIdis removed. Your backend sets the workflow when it creates the transaction.url,additionalRequestHeaders, and the proxy paths (getWorkflowInfo,startTransaction, andcancelWorkflow) are removed. The SDK talks to the Platform directly.consentis removed, together withMicroblinkPlatformConsent. Collect the consent in your app before the verification starts; your backend sends it when it creates the transaction.correlationIdis removed. Your backend sends it when it creates the transaction, in thecorrelationIdfield ofPOST /api/v2/transaction.ServiceSettingshas a new optionalretryPolicy, which controls how often the SDK retries a failed or busy request. The default,NetworkRetryPolicy(maxAttempts: 5, retryDelay: 0.5), is a good fit for most apps.
Results
The three delegate methods become cases of MicroblinkPlatformEvent, which your onEvent closure receives.
None of them pass a view controller; you dismiss what you presented.
microblinkPlatformSDKDidFinish(viewController:result:)becomes.finished(MicroblinkPlatformResult). It's sent after the user closes the result screen.result.statusis replaced byresult.outcome, aSessionOutcome. For a completed verification, that's.verification(transactionId:state:), wherestateis.accept,.reject, or.review.result.transactionIdis now optional.microblinkPlatformSDKDidClose(viewController:cancelState:)becomes.canceled(MicroblinkPlatformCancelState). It's also sent when the user closes an error screen that doesn't offer a retry.cancelState.cancelReasonis renamed tocancelState.reason, and its typeMicroblinkPlatformCancelReasonis replaced byCancelReason. TheconsentDeniedreason is removed, because the SDK no longer handles consent. The newunsupportedWorkflowVersionreason means that the workflow is older than the SDK supports.microblinkPlatformSDKDidFinishCardScanStep(viewController:cardScanResult:)becomes.cardScanned(CardScanResult). The verification continues after it, so don't dismiss the SDK.MicroblinkPlatformResultCardScanResultis replaced byCardScanResult. Its fields keep their names:cardNumber,expiryDate,owner, andcvv.cardNumberis now optional, and the newisCardNumberValidsays whether the number passed validation.
Customization
You still customize our screens through MicroblinkPlatformTheme.shared, and set it before you create the view.
The properties keep their names, but they now take SwiftUI types instead of UIKit ones:
UIColoris replaced byColor.UIFontis replaced byFont.UIImageis replaced byImage.
There are also new general properties: titleColor, subtitleColor, accentColor, backgroundColor, and errorColor.
The document scanning properties (documentScanAlertTitleColor, documentScanOnboardingSheetTitleFont, and so on) are now grouped in MicroblinkPlatformTheme.shared.documentScannerAppearance, with the same names.
You can still set them directly on MicroblinkPlatformTheme.shared, but they're now optional.
Card scanning can now be customized too, through MicroblinkPlatformTheme.shared.cardScannerAppearance.
Face capture now uses the screens of Microblink's face capture SDK.
Customize them through MicroblinkPlatformTheme.shared.faceCaptureAppearance.
primaryColor doesn't change the colors of the scanning screens.
localizationBundle and localizationTableName work as before, and the existing translation keys keep their names, except that these are no longer used:
mb-mp-consent-*, because the SDK no longer shows a consent screen.mb-mp-face-capture-*andmb-mp-portrait-mode-*, because face capture now uses its own screens.
V2 also adds new keys for its new screens and messages, for example mb-mp-button-continue, mb-mp-result-accept, and mb-mp-upload-camera.
If you translate the SDK, add the new keys from the SDK's Localizable.xcstrings to your strings; until you do, the SDK shows its English text for them.
Read Localization.