Skip to main content

NFC

You can access the ScanNFC module from the base Amani class as shown below.

let amaniScanNFC = Amani.sharedInstance.scanNfc()

There are tree ways to start the NFC capture process.

Starting the NFC Capture with NVI Data

In this scenario, you need to gather some information that can be found on ID from the user.

In order to capture NFC without capturing the ID first, and upload the data as a separate document you need to call setType as documentTypes.NFCDocument.rawValue

note

If you have an another type supplied from us please use it.

amaniScanNFC.setType(type: documentTypes.NFCDocument.rawValue)

let nviData = NviModel(documentNo: "DOCUMENT NO IN ALL CAPS", dateOfBirth: "YYMMDD", dateOfExpire: "YYMMDD")

try amaniScanNFC.start(nviData: nviData) {(data, error) in
//data in NFCRequest type and it contains nfc information, if there is an error this value can be null
//error in AmaniError type and if there is no error it can be null
guard let data:NFCRequest = data else {
return
}
} catch {

}

Starting the NFC capture with image of the MRZ sided ID

If you cache the back side of the ID, or the image of the passport itself, you can call the function below to start the nfc capture process.

idCardType parameter is the type that you've used while capturing the image.

try amaniScanNFC.start(idCardType: "XXX_ID_0", imageBase64: base64MRZImageData) {(data, error) in 
//data in NFCRequest type and it contains nfc information, if there is an error this value can be null
//error in AmaniError type and if there is no error it can be null
guard let data:NFCRequest = data else {
return
}
}

Starting the NFC capture with ID Capture

You can also capture the MRZ side yourself with this function. It'll return an instance of UIView, so you'll need to capture the correct side of the ID.

note

If you want the NFC capture with process of ID Capture, please check out scanning the nfc section on ID Capture Page.

caution

Please don't forget the change the XXX_ID_0 to a type given by Amani.

self.captureView = amaniScanNFC.start(idCardType: "XXX_ID_0") {(data, error) in
//data in NFCRequest type and it contains nfc information, if there is an error this value can be null
//error in AmaniError type and if there is no error it can be null
guard let data:NFCRequest = data else {
return
}

DispatchQueue.main.async {
self.captureView.removeFromSuperview()
}
}

DispatchQueue.main.async {
self.view.addSubView(self.captureView)
}

Upload

After completing the capture process you can call the upload as shown below.

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