Initalize API
Overview
The first step is always initializing the API. You need to do this before any other action otherwise the SDK will not work. You need your license key to complete this step:
// define a property to keep the reference to MobbScanAPI
var mobbscanAPI:MobbScanAPI = MobbScanAPI.getInstance()
...
self.mobbscanAPI.initAPI(withLicense: "YOUR_LICENSE_HERE") { (result, date) in
NSLog("License check result: %@", NSStringFromMobbScanLicenseResult(result))
}
// define a property to keep the reference to MobbScanAPI
@property (nonatomic, strong) MobbScanAPI *mobbScanAPI;
...
self.mobbScanAPI = [MobbScanAPI getInstance];
[self.mobbScanAPI initAPIWithLicense:@"YOUR_LICENSE_HERE" result:^(MobbScanLicenseResult result, NSDate* date) {
NSLog(@"License check result: %@", NSStringFromMobbScanLicenseResult(result));
}];
[self.mobbScanAPI setBaseURL:@"YOUR_MOBBSCAN_SERVER_HERE"];
Setting up the SDK Parameters
You can configure the URL of the MobbScan backend. This operation must be performed after the SDK initialization or you will be using the default value: https://demo.mobbeel.com
. In order to choose another URL:
self.mobbscanAPI.baseURL = "YOUR_MOBBSCAN_SERVER_HERE"
[self.mobbScanAPI setBaseURL:@"https://yourmobbscaninstance.yourcompany.com"];
Note: As of 2.22.0 version, MobbScan only supports online mode, thus setting
apiMode
property toOFFLINE
value has no effect.
Start Process
Once the API is initialized and the SDK is configured as you need, you have to start a new scan process.
self.mobbScanAPI.startScan(for: ._ESPIDCard, for: .SCAN_BOTH_SIDES, withResult: { result,scanId,error in
// Your block code here
})
[self.mobbScanAPI startScanForDocumentType:MobbScanDocumentType_ESIDCard forMode:MobbScanOperationMode_SCAN_BOTH_SIDES withResult:^(MobbScanStartScanResult result, NSString* scanId, NSError* error) {
// Your block code here
}];
The first parameter of the method startScan
is the document type to be scanned. The second one indicates if you want to do a full scan with both sides of the document or just one of them.
Tip: The listener will return you a
scanId
string. Be sure of saving it, as you will need it for next API calls and for retrieving evidences after the scan process.
Warning: When you are going to scan a document with just one side (such as Passport_TD3), you must use the scan operation
SCAN_ONLY_BACK
.