Configuration
The iOS SDK is configured through EngineConfiguration, which you pass to MicroblinkPlatform.view(configuration:onEvent:):
let configuration = EngineConfiguration(
service: ServiceSettings(sdkConfiguration: "...")
)
let verificationView = MicroblinkPlatform.view(configuration: configuration) { event in
// handle events
}
See the quick start and Integration for full SwiftUI and UIKit examples.
The configuration covers the connection to the Platform, and optionally the appearance of the scanning screens.
Everything else about the verification, such as the steps and their order, comes from the workflow and the transaction that your backend created.
You customize our screens separately, through MicroblinkPlatformTheme.shared.
Configuration objects
let configuration = EngineConfiguration(
service: ServiceSettings(
sdkConfiguration: "...", // required
retryPolicy: NetworkRetryPolicy() // optional
),
scannerAppearance: ScannerAppearance() // optional
)
let verificationView = MicroblinkPlatform.view(
configuration: configuration, // required
onEvent: { event in ... } // required
)
EngineConfiguration, ServiceSettings, NetworkRetryPolicy, and ScannerAppearance come from the core library, MicroblinkPlatformEngine.
Required fields
sdkConfiguration
ServiceSettings(
sdkConfiguration: sdkConfiguration
)
The sdkConfiguration value that your backend received when it created the transaction with POST /api/v2/transaction.
Pass it as it is; don't parse or modify it.
Read Backend.
It authorizes the SDK for this one transaction, so treat it as a secret, and don't log it.
onEvent
MicroblinkPlatform.view(configuration: configuration) { event in
switch event {
case .finished(let result): ...
case .canceled(let cancelState): ...
case .cardScanned(let card): ...
@unknown default: ...
}
}
The closure that receives what happens in the verification, as a MicroblinkPlatformEvent.
See Events.
Optional fields
retryPolicy
ServiceSettings(
sdkConfiguration: sdkConfiguration,
retryPolicy: NetworkRetryPolicy(maxAttempts: 5, retryDelay: 0.5)
)
How often the SDK retries a request that failed or that the Platform couldn't process yet, before it reports an error:
maxAttempts: the maximum number of attempts for each request to the Platform. Retries and polling share this budget. Default:5.retryDelay: how long the SDK waits, in seconds, between attempts when the Platform doesn't name a delay. Default:0.5.
The default is a good fit for most apps.
scannerAppearance
EngineConfiguration(
service: ServiceSettings(sdkConfiguration: sdkConfiguration),
scannerAppearance: ScannerAppearance(
localizationTableName: nil,
documentScannerAppearance: nil,
cardScannerAppearance: nil,
faceCaptureAppearance: nil
)
)
The appearance of the document scanning, card scanning, and face capture screens.
All of its fields are optional.
With our screens, you usually leave it out, and set the same values through MicroblinkPlatformTheme.shared instead.
Our screens use the theme's value for each field that is nil, and don't merge the theme into a value you set.
Customization
// Colors
MicroblinkPlatformTheme.shared.accentColor = myColor
MicroblinkPlatformTheme.shared.backgroundColor = myBackgroundColor
// Images
MicroblinkPlatformTheme.shared.mainScreenMainImage = myHomeImage
MicroblinkPlatformTheme.shared.verifySuccessImage = mySuccessImage
MicroblinkPlatformTheme.shared.verifyReviewImage = myReviewImage
MicroblinkPlatformTheme.shared.verifyErrorImage = myErrorImage
MicroblinkPlatformTheme.shared.cameraPermissionIcon = myCameraIcon
// Fonts
MicroblinkPlatformTheme.shared.mainScreenTitleFont = myTitleFont
MicroblinkPlatformTheme.shared.mainButtonFont = myButtonFont
// Shape
MicroblinkPlatformTheme.shared.buttonCornerRadius = 24
Set the theme before you create the view.
The properties take SwiftUI types: Color, Font, and Image.
Read more about how to customize your iOS SDK integration.
Events
Your onEvent closure receives .finished or .canceled exactly once, when the verification ends.
None of the events pass a view controller; you dismiss what you presented.
Verification finished
case .finished(let result):
if case .verification(let transactionId, let state) = result.outcome {
print(transactionId, state)
}
dismiss()
Sent after the user closes the result screen.
MicroblinkPlatformResult contains:
outcome: aSessionOutcome. For a completed verification, that's.verification(transactionId:state:), wherestateis.accept,.reject, or.review. Otherwise, it's.canceled(CanceledOutcome), so receiving.finisheddoesn't mean that the verification was accepted.transactionId: the unique identifier of the transaction, if available
User exited
case .canceled(let cancelState):
print(cancelState.reason)
dismiss()
Sent when the user leaves the verification before it finished, and when they close an error screen that doesn't offer a retry.
MicroblinkPlatformCancelState contains:
reason: aCancelReasonvalue:.userCanceled: the user left the verification..unsupportedWorkflowVersion: the workflow is older than the SDK supports, and the user closed the error screen.
transactionId: the transaction ID, if available at the time of cancellation
Card scanned
case .cardScanned(let card):
print(card.cardNumber ?? "", card.expiryDate ?? "")
Sent when a card scanning step finishes. The verification continues after it, so don't dismiss the view.
CardScanResult contains cardNumber, expiryDate (in MM/yyyy format), owner, and cvv, which are all optional, and isCardNumberValid, which says whether the card number passed validation.
Its description hides most of the card number, the owner, and the CVV, so that logging it doesn't leak the card.