Getting started with MobbSign
Initialization
First step is always initializing the API. You need to this before any other action or SDK will not work. You need your license key to complete this step.
So, set up the license id and listen to the possible result:
from [mobbSignView configureLicense: complete:] to [mobbSignView configureLicense: status:] where status block receives license status enum and expiration date, so preferred configure license method will look like:
[mobbSignView configureLicense:@"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" status:^(MobbSignLicenseResult result, NSDate *expirationDate) {
switch (result) {
case MobbSignLicenseResult_DEVICES_EXCEEDED:
case MobbSignLicenseResult_EXPIRED:
case MobbSignLicenseResult_NOT_VALID: {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"License Invalid" message:@"License is not valid" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
break;
}
case MobbSignLicenseResult_GRACE_PERIOD:
NSLog(@"License in grace period (expires %@)", expirationDate);
break;
case MobbSignLicenseResult_VALID:
NSLog(@"Valid license (expires %@)", expirationDate);
break;
default:
break;
}
}];
- Current [mobbSignView configureLicense: complete:] is now deprecated and will be removed when MobbSignSDK 3.0 ships.
Configuring the SDK
Configure the public key that is going to be used to encrypt the biometric data embedded to the document:
NSString* keyPath = [[NSBundle mainBundle] pathForResource:@"public" ofType:@"key"];
[mobbSignView setEncryptionKey:keyPath];
NOTE: A test public key is delivered with the simple demo project, but you will need a production one before launching your product.
Define your own listeners and implement the events you need to know about:
[self.mobbSignView setOnDocumentShown:^(BOOL)editable
{
NSLog(@"onDocumentShown");
}];
[self.mobbSignView setOnDocumentSigned:^(NSData *signedDocument, NSData *encryptedSignatureData, UIImage *signatureImage, NSInteger signaturePage, CGRect signatureCoord)
{
NSLog(@"onDocumentSigned");
}];
[self.mobbSignView setOnSignatureAcquised:^
{
NSLog(@"onSignatureAcquised");
}];
[self.mobbSignView setOnSignatureDeleted:^
{
NSLog(@"onSignatureDeleted");
}];
[self.mobbSignView setOnProcessEnd:^(NSData *signedDocument)
{
NSLog(@"onProcessEnd");
}];
[self.mobbSignView setOnErrorOccurred:^(int errorCode)
{
NSLog(@"onErrorOccurred");
}];
[self.mobbSignView setOnBackButtonPressed:^
{
NSLog(@"onBackButtonPressed");
}];
[self.mobbSignView setOnSignButtonPressed:^
{
NSLog(@"OnSignButtonPressed");
}];
[self.mobbSignView setOnActivePenStatusChanged:^
{
NSLog(@"OnActivePenStatusChanged");
}];
[self.mobbSignView setOnLocationRetrieved:^(MobbSignLocationResult result)
{
NSLog(@"OnLocationRetrieved");
}];
Start process
Once the API is initialized and the SDK is configured as you need it, you have to start a new scan process.
Let's go to load the document:
NSString* fullPath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];
[mobbSignView loadPDFDocument:fullPath name:@"Sample document"];
Different ways to load documents
From document source:
- (void)loadPDFDocument:(NSString*)path name:(NSString*)name;
From document source with data on editable document fields:
- (void)loadPDFDocument:(NSString*)path name:(NSString*)name fields:(NSDictionary*)fields;
Passing data file content:
- (void)loadPDFDocumentFromData:(NSData*)documentData name:(NSString*)name;
Passing data file content with preloading data on editable document fields:
- (void)loadPDFDocumentFromData:(NSData*)documentData name:(NSString*)name fields:(NSDictionary*)fields;