Skip to main content
Version: iOS SDK Latest (6.0.0)

Core

Introduction

The Core module is the main component of Verifai. Everything that is needed to scan documents and communicate with our backend services, is available in the Core module.

Use the Core module when you would like to quickly read and process the information on a user's identity document. If you also want to verify the document itself for validity, then the NFC module is the best option. The NFC module will automatically handle a Core scan that facilitates its scanning flow.

Example

Verifai can be configured and started with just a few lines of code. The code example below shows how to quickly run the SDK in its default configuration:

Default Core scan
do {
try Verifai.start(over: self) { result in
switch result {
case .failure(let error):
print("Error or cancellation: \(error)")
case .success(let successResult):
// Continue with the result
let mrzData = successResult.mrzData
// Print the given names
print("Given names: \(mrzData?.givenNames)")
}
}
} catch {
print("🚫 Unhandled error: \(error)")
}
Default Core scan with Swift's concurrency
do {
let result = try await Verifai.start(over: self)
// Continue with the result
let mrzData = result.mrzData
// Print the given names
print("Given names: \(mrzData?.givenNames)")
} catch {
print("🚫 Error or cancellation: \(error)")
}

The result received immediately has some information from the document. This info can be used for displaying purposes. For the verified information will be available through webhooks in your backend.

Configuration

Options

The Core module has the following configuration options:

SettingDescriptionAdds validatorDefault
enableCroppingControls the cropping interaction-true
enableManualFlowControls if you can manually draw masking-true
requireDocumentCopyIf false, you won't go to automatic mode and correction screens-true
requireCroppedImageIf false, you will receive a full image taken and not only the document-true
requireMrzIf true, it adds a validator and disables all docs without MRZHasMrzfalse
requireNFCWhenAvailableAdds an NFC key validator if the document has an NFC chipNfcKeyWhenAvailablefalse
enableVisualInspectionWhether the Visual inspection zone on the document should be OCR'ed-false

Extra configuration options:

Configuration optionDescriptionDefault value
validatorsArray of validators that will be run after the automatic or manual scansempty VerifaiValidator array
documentFiltersArray of document filters that determine which documents a user can select in the manual flowempty VerifaiDocumentFilter array
autoCreateValidatorsWhether setting document filters automatically creates validators for the automatic scan viewstrue
customDismissButtonTitleDismiss button string valuenil
instructionScreenConfigurationHow the instruction screens are setup in the SDK. Including the ability to hide / customize individual ones with custom text or an URLAll instruction screens are shown in default mode
scanHelpConfiguration (iOS)How the scan help throughout the flow should be configuredDefault VerifaiScanHelpConfiguration settings.

Note on the Dismiss button

On iOS it's also possible to configure the dismiss bar button item title for the modally presented Verifai view. To do this set the value of customDismissButtonTitle inside the VerifaiCoreConfiguration. It is your responsibility to provide the string with the right translation. If no string is provided then Verifai will default to using Cancel. In that case, when no string is provided, Verifai will also take care of translating the default string.

Example

In order to set a custom configuration for Verifai you have to supply a VerifaiCoreConfiguration. This configuration can then be set using Verifai.configure(with:), during which the configuration will be checked for errors.

Setting up the configuration
let config = VerifaiCoreConfiguration(requireDocumentCopy: true,
requireCroppedImage: true,
requireNFCWhenAvailable: true)

// Extra configuration

// Instruction screens (optional)
let instructionScreenConfiguration =
try VerifaiInstructionScreenConfiguration(instructionScreens: [
.documentPickerInstruction: .defaultScreen,
.mrzPresentFlowInstruction: .hidden
])
config.instructionScreenConfiguration = instructionScreenConfiguration
do {
try Verifai.configure(with: config)
} catch VerifaiConfigurationError.invalidConfiguration(let description) {
print("🚫 Invalid configuration: " + description)
} catch {
print("🚫 An error occurred while setting the configuration: \(error)")
}

Result

After scanning a document through the Verifai flow, the SDK will return a VerifaiCoreResult object. The object does not contain all of the information on a document. It's meant to be used as a bridge to allow use of the Verifai API with other modules. Or to return references provided when the scan was started.

The items in the results that might be of relevance for reference purposes are:

  1. frontImage: Picture of the front (UIImage)
  2. mrzData: The MRZ data if any read from the document

The rest of the values get used to help other Verifai modules to perform Verifai compliant scans.

Errors

What follows is an overview of the errors Verifai can return with a description of what causes them.

ErrorTypeDescriptionPossible solutions
flowCancelledVerifaiFlowCancelErrorThe user cancelled out of the flowShow an error condition or ask the user to retry
neuralNetworkLoadingFailedVerifaiFlowCancelErrorSomething went wrong loading the neural networkMake sure an internet connection is active and retry
invalidConfiguration(_ description: String)VerifaiConfigurationErrorThe configuration provided in Verifai.configure(with: is invalid.Check the description in the error, fix your configuration and retry.
permissionDeniedVerifaiCameraErrorThe user denied the camera permission requestRequest your user to go to your app's setting and enable the camera permission
slowNetwork(_ timeout: TimeInterval)VerifaiNetworkErrorA timeout on the network has been detectedCheck your internet connection and retry
invalidRequest(_ underlyingError: Error?)VerifaiNetworkErrorAnd invalid request was triggered by the OSCheck the underlying iOS error for more info
downloadFailed(_ underlyingError: Error?)VerifaiNetworkErrorA download operation failedCheck the underlying iOS error for more info