Skip to main content

ID Capture

You can access the ID Capture module from the sharedInstance property as shown below.

caution

Before using this module please make sure you've initialized the SDK correctly.

let amaniIDCapture = Amani.sharedInstance.IdCapture()

Setting the type

Since we support many ID cards and passports you need to set the type before setting the actual type of the ID or passport with setType method. This type is supplied by Amani.

amaniIDCapture.setType("XXX_ID_0")

XXX_ID_0 is the example. You have to specify the type that provided by Amani.

caution

If you don't specify the type, SDK will throw an exception.

Setting the Manual Crop timeout

The setManualCropTimeout() sets the manual capture button of the IDCapture fragment for the situations where AutoCapture can fail. When the manual crop button is enabled, user will have a chance to capture the document manually for unexpected situations.

If you did not called this method. It will use the default value as 30 seconds.

amaniIDCapture.setManualCropTimeout(Timeout: 30)

Starting the document

ID Card's has 2 sides, so we have to tell the start method to capture which side of the ID we're taking by setting the stepId parameter.

Callback on the start method will return UIImage so you can preview before upload. The method itself will return an instance of UIView. You should add this as a subview to your view controller.

// stepId is the document page count. This value is calculated as n-1
// for example 2 sided ID Card has stepId 0 for front and 1 for back.
self.idCaptureView = amaniIDCapture.start(stepId: 0) {[weak self] idImage in
// idImage is UIImage that you can use to preview
// TODO: Show a preview screen or directly start the back side

// After the callback ends don't forget to remove the idCaptureView from your controller
DispatchQueue.main.async {
self.idCaptureView.removeFromSuperview()
}

}

Scanning the NFC

If you want to capture the NFC data can be found inside the ID as a part of the ID document you can use the startNFC method before uploading the document.

Starting the NFC Capture

There are two ways to capture the NFC Data as a part of the ID.

Capturing the NFC data after ensuring both sides are captured and before the upload.

amaniIDCapture.startNFC() {[weak self] captureSuccess in
// captureSuccess is a boolean variable
// you can use this to restart the nfc capture process, or skip nfc altogeter
if (captureSuccess) {
// you can start the upload proccess here.
} else {
// restart the nfc capture again
}
}

Starting the NFC Capture with NVI data

NviModel contains some information about the ID that we need to read the NFC data.

let nviData = NviModel(
documentNo: "Documnet number on id",
dateOfBirth: "YYMMDD",
dateOfExpire: "YYMMDD"
)

amaniIDCapture.startNFC(nvi: nviData) {[weak self] captureSuccess in
// captureSuccess is a boolean variable
// you can use this to restart the nfc capture process, or skip nfc altogeter
if (captureSuccess) {
// you can start the upload proccess here.
} else {
// restart the nfc capture again
}
}

Upload the document

After all sides are captured, you can upload the captured document by using the upload method on the IdCapture module.

The first parameter on the callback states if the upload has completed successfuly.

Final validation response will be delivered from AmaniDelegate.onStepModel delegate method.

idCaptureModule.upload(location: nil) {[weak self] (uploadSuccess, error) in
if (uploadSuccess != nil) {
// uploadSuccess is a boolean variable
// Upload successfuly completed
// TODO: handle the upload state
} else if (error != nil) {
// TODO: handle the error
}
}