Quick start
This guide walks you through a complete signature: your app shows a PDF, the user reads it and signs it with their handwritten signature, and the SDK returns the signed document with the encrypted biometric data embedded.
| # | Step | Call |
|---|---|---|
| 1 | Add the view | MobbSignView |
| 2 | Configure the license | configureLicense |
| 3 | Set the encryption key | setEncryptionKey |
| 4 | Listen to the events | setOn… |
| 5 | Load the document | loadPDFDocument |
The SDK is installed and you have a license key and the public encryption key of your project.
1. Add the view
MobbSignView displays the document, its toolbars and the signature capture. Create it in your view controller:
- (void)viewDidLoad {
[super viewDidLoad];
self.mobbSignView = [[MobbSignView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.mobbSignView];
}
To customise the view, pass a customisation dictionary:
NSMutableDictionary *customDict = [[NSMutableDictionary alloc] init];
[customDict setObject:[UIColor blueColor] forKey:kMobbSign_SIGNATURE_STROKE_COLOR];
self.mobbSignView = [[MobbSignView alloc] initWithFrame:self.view.bounds customizationDictionary:customDict];
Present the view controller that contains MobbSignView full screen:
[viewController setModalPresentationStyle:UIModalPresentationFullScreen];
2. Configure the license
Configure the license before any other call. The block receives the result of the validation and the expiry date:
[self.mobbSignView configureLicense:@"YOUR_LICENSE_KEY" status:^(MobbSignLicenseResult result, NSDate *expirationDate) {
if (result != MobbSignLicenseResult_VALID && result != MobbSignLicenseResult_GRACE_PERIOD) {
// Inform the user: documents can be viewed, but not signed
}
}];
3. Set the encryption key
Pass the path of the public key of your project. It encrypts the biometric data of every signature:
NSString *keyPath = [[NSBundle mainBundle] pathForResource:@"public" ofType:@"key"];
[self.mobbSignView setEncryptionKey:keyPath];
The test key included with the sample project is only for development. Before you release your app, replace it with the public key generated for your project.
4. Listen to the events
Set the blocks you need. These three cover a basic integration:
[self.mobbSignView setOnDocumentSigned:^(NSData *signedDocument, NSData *encryptedSignatureData, UIImage *signatureImage, NSInteger signaturePage, CGRect signatureCoord) {
// A signature has been added to the document
}];
[self.mobbSignView setOnProcessEnd:^(NSData *signedDocument) {
// The user has finished: `signedDocument` contains the signed PDF
}];
[self.mobbSignView setOnErrorOccurred:^(int errorCode) {
// An error has occurred
}];
See all the events in Configuration.
5. Load the document
Load the PDF to sign. name is the title shown in the viewer:
NSString *path = [[NSBundle mainBundle] pathForResource:@"contract" ofType:@"pdf"];
[self.mobbSignView loadPDFDocument:path name:@"Service contract"];
The viewer opens the document. The user can turn the pages and zoom in, tap Sign to draw their signature and confirm it. When they finish, onProcessEnd delivers the signed PDF.
6. Keep the signed document
onProcessEnd returns the signed PDF. From that moment your app is responsible for the document: send it to your backend, store it and keep it for the period required.
Next step
Learn the license states, all the events and the ways to load a document in Configuration.