iOS - ID Parsing SDK
IDScan offers two SDKs for iOS. The ID Parsing SDK for iOs allows information from Drivers Licenses and IDs captured by hardware scanners to be parsed into an iOS application.
ID Parsing SDK - Download
Implementation
DL/ID cards are widely used for storing personal information such as first name, last name, birth date, address, hair color, etc. They also contain special information related to driving activity including DL number, class and restrictions. Because of the utility of this data, there is a high demand for mobile applications that can scan and process DL/ID information.
As a solution, IDScan.net developed a DL/ID Parsing Component for iOS. We collected 10+ years of ID formats from the US and Canada and tested each one to ensure every DL/ID card is parsed with precision. Our DL/ID Parsing Component allows data collection from the following fields:
Document Info: | Customer Info: |
License Number, Expiration Date, Issue Date, Issued By, IIN, Endorsements Code, Classification Code, Restrictions Code, Specification | Full Name, Last Name, First Name, Middle Name, Name Prefix, Name Suffix, Birthdate |
Customer address: | Customer physical description: |
Address1, Address2, City, State/Jurisdiction Code, Postal Code, Country | Gender (Male or Female), Race, Eye Color, Height, Weight, Hair Color |
Objective-C
The DL Parsing Component enables DL/ID parsing capabilities for iOS applications.
It consists of the following file: idscanParser.framework
Add idscanParser.framework in Embedded Binaries and then import <idscanParser/idscanParser.h> into your View Controller or other script.
idscanParser.framework parses information scanned from most ID scanners and stores the information in an object called DriverLicense
. The code below stores the DriverLicense
object in variable dl
, then outputs the parsed information to a text box. If the parsing fails, it will log a -Failed- message instead.
/* Input string from magnetic stripe scanners should be composed from tracks separated by any of the following symbols \r\n, \n\n, \r, \n.*/
DriverLicense *dl = [[DriverLicense alloc] init];
NSString* output = nil;
if ([dl parseDLString:inputText hideSerialAlert:(self.chkShowSerial.isOn==NO)] == NO){
output = @"Failed" ;
}else{
output = [[dl fields] description];
}
textView.text = [NSString stringWithFormat:@"%@\n=======\n%@",output,[DriverLicense dlpUniqueId]];
[dl release];
You can enable/disable parser debug info with showLogs method. Disabled by default
- (void)showLogs:(BOOL)showLogs;
To access the parsed information in code, you can access the parsed information field by field:
firstName = dl.firstName;
lastName = dl.lastName; //etc. The rest of the fields can be found in DriverLicenseParser.h
//Alternatively, use "valueForField:[field]"
//this returns string value for field (for Birthdate and ExpirationDate fields returns string in the format yyyyMMdd, for Gender field returns -Male- or -Female-)
[dl showLogs:NO];
//For example:
birthDate = [dl valueForField:@"Birthdate"]; //19890525
//Dates can be stored in different formats with "valueForDateField" as seen below birthDate = [dl valueForDateField:@"Birthdate" withFormat:nil]; //Birthdate as NSDate
birthDate = [dl valueForDateField:@"Birthdate" withFormat:@"MM/dd/yyyy"]; //Birthdate as a formatted string: 05/25/1989
You can also access the parsed information via the NSDictionary fields
, as in the example above, which contains all of the information from the various fields. The NSArray availableFields
contains a list of the names of all the fields that were parsed.
SWIFT
Using the Parser Library in SWIFT application does not differ in coordination from the Objective-C Application, you just need to graft the framework to you project by correct way.
- Add idscanParser.framework to you project
- Import idscanParser.framework to you project
- Set idscanParser.framework to Embed & Sign
- OK, time to make some code. You do not need to insert the library header in each controller, where you want to use it because the framework is visible throughout the project area. Just make an instance of class and use it by calling ParseDLString method.
let dl = DriverLicense()
dl.parseDLString(, hideSerialAlert: )
var outputString : String = ""
for (key , value) in dl.fields! {
outputString += "\(key.description) : \(value)\n"
}
print(outputString)
Please note, in demo mode (without the serial key) almost all fields will be displayed as DEMO. To change it you should put KEY to dlpSerial.txt file.
Working with the Demo
In the SDK, the folder -TestReader- contains a simple test project, which demonstrates the functionality of IDScan-s DL/ID Parser Component with most iOS hardware scanners.
-Connecting Action:
After swiping an ID card you will get the following information
In demo mode (without serial #) almost all fields will display DEMO
value
Do not forget to point out the appropriate Bundle identifier in DlpTest-Info.plist
to work with a real device.
How to Activate
Obtaining a License Key
In order to receive the License Key send an email to support@idscan.net with the Bundle ID. Please be sure to provide your order number in the email once ready to upgrade from trial to production mode. A unique Serial number/Registration Key for this Bundle ID.
There are two ways to apply the serial number.
- During design time, paste the serial number in the file
dlpSerial.txt
in XCode. The file should contain only the serial number. See the screenshot below:
- To allow the end user to enter the serial, do it programmatically - by applying the method
(yourserial = generated string)
[[NSUserDefaults standardUserDefaults] setValue:yourserial forKey:@"DriverLicenseParserCurrentSerial"];
Click on -Enter DLP serial- to enter serial key.