Parse barcodes on North American ID cards encoded using AAMVA standard.
-
Install CocoaPods.
-
Add a file called Podfile in your project's root folder.
-
Refer to the Podfile reference documentation to set up your Podfile.
-
Add the AAMVA Barcode Parser dependency in your Podfile:
pod 'AAMVA-Barcode-Parser', '~> 1'
-
Open Terminal, navigate to the folder with your Podfile and enter:
pod install
import AAMVABarcodeParser
/// Parse barcode data
/// - Parameter barcodeData: Barcode data scanned from the back of a North American ID card
/// - Returns: Parsed document data
func parseBarcodeData(_ barcodeData) -> DocumentData {
let parser = AAMVABarcodeParser()
let documentData = try parser.parseData(barcodeData)
if let firstName = documentData.firstName, let lastName = documentData.lastName {
NSLog("Parsed ID card belonging to %@ %@", firstName, lastName)
}
return documentData
}