Give us a call
Call us at +41 41 555 20 40
MRZ Reader SDK: kds-mrz-reader-sdk-ios-release
Read me for framework version: 1.9.x
The MRZ reader could detect and parse the five main types of Machine Readable Travel Documents, according to ICAO:
Inside the folder Example
there is an Xcode project, that shows the usage of the SDK.
The easiest way is to use CocoaPods. It takes care of all required frameworks and dependencies. Just add this line to your Podfile
pod 'kds-mrz-reader-sdk-ios-release',
:git => 'https://git.yourdomain.com/kds-mrz-reader-sdk-ios.git'
or (for local usage)
pod 'kds-mrz-reader-sdk-ios-release', :path => '../kds-mrz-reader-sdk-ios'
As this SDK is build as a dynamic framework, you have to use the target parameter use_frameworks!
in the Podfile. After pod install
the sdk is ready to use in your app.
To use the SDK, you have to import the module:
import kds_mrz_reader_sdk_ios
To use the MRZ reader in your app, instantiate the viewcontroller using the static function createInstance
:
let kdsMrzScanner = KDSMrzRootVC.createInstance(delegate: self)
self.present(kdsMrzScanner, animated: true, completion: nil)
The mrzVC will call the related delegate methods defined in the protocol KDSMrzScannerVCDelegate
:
extension YourViewController : KDSMrzScannerVCDelegate {
func scanMrzDidComplete(withMrzInfo mrzInfo: MrzInfo) {
debugPrint("scanMrzDidComplete: \(mrzInfo)")
}
func scanMrzDidComplete(withIdlInfo idlInfo: IdlInfo) {
debugPrint("scanMrzDidComplete: \(String(reflecting: idlInfo))")
}
func scanMrzDidComplete(withParsingError error: MrzParserError) {
debugPrint("scanMrzDidCompleteWithError: \(error)")
}
func scanMrzDidCancel() {
debugPrint("scanMrzDidCancel: User cancelled Scan")
}
func scanMrzDidSkipScanning() {
debugPrint("scanMrzDidSkipScanning: User skipped Scan")
}
}
The appearance of the mrz reader vc could be modified using a configuration struct.
...
let configuration = KDSMrzScannerConfiguration(
navBarColor: UIColor.darkGray,
navBarTintColor: UIColor.white,
displayTopInfo: KDSMrzHintText.text(hintText: "Customized Guidance Text"),
displaySkipButton: true,
shouldRotateImage: true,
detectionMode: KDSMrzDetectionMode = .mrzTextAndPdf417
)
//present the KDSMrzRootVC modally
let kdsMrzScanner = KDSMrzRootVC.createInstance(
delegate: self,
withConfiguration: configuration)
self.present(kdsMrzScanner, animated: true, completion: nil)
...
To hide the top info bar completely, just use the ...displayTopInfo: KDSMrzHintText.hidden
enum value.
MrzInfo
The delegate method scanMrzDidComplete(withMrzInfo mrzInfo: MrzInfo)
contains a struct of type MrzInfo
as result. This struct contains all parsed values from the MRZ:
public struct MrzInfo {
public let documentCode: String
public let documentNumber: String
public let surname: String
public let givenNames: String
public let gender: String
public let dateOfBirth: Date
public let dateOfExpiry: Date
public let nationality: String
public let issuingState: String
public let optionalData: String
}
MrzParserError
If there was a problem parsing the mrz the delegate method scanMrzDidComplete(withParsingError error: MrzParserError)
contains an enum which specifies the problem:
public enum MrzParserError: Error {
case invalidCheckSum(field: MrzParserCheckSumField)
case invalidLength
case invalidStructure
case notRecognized
}
If the error is from type invalidCheckSum
it contains the field for which the checksum doesn’t match:
public enum MrzParserCheckSumField {
case documentNumber
case birthDay
case expiryDay
case composite
case personalNumber
}
NSCameraUsageDescription
in Host AppAs the KDSMrzScannerVC needs camera access, the host app have to put a usage description inside it’s Info.plist, otherwise the app crashes. Please add a string like this to the Info.plist of the host app:
NSCameraUsageDescription
$(PRODUCT_NAME) needs camera access to scan your documents.
Give us a call
Call us at +41 41 555 20 40
Contact by e-mail
Contact us via our contact form.
Personal meeting
Arrange a personal meeting.