Skip to main content

Quick start

This guide signs a document from a Cordova, Ionic or Capacitor app. The plugin exposes the global object MobbSignAPI. Every method receives a success callback and a failure callback.

#StepCall
1Wait for the devicedeviceready
2InitialiseinitMobbSignWithLicense()
3Choose the interfacesetSignDocumentInterface()
4Listen to the eventssetOn…Listener()
5SignsignDocument()

1. Wait for the device​

The plugin is available once Cordova fires the deviceready event:

document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady() {
// Initialise MobbSign here
}

2. Initialise the plugin​

Initialise the plugin with your license key. MobbSignAPI is ready when the success callback is called:

MobbSignAPI.initMobbSignWithLicense('YOUR_LICENSE_KEY', onReady, onError);

3. Choose the signing interface​

Set the native screen that displays the document and captures the signature. The plugin includes a default interface, SignDocumentInterfaceDefault; you can also build your own:

MobbSignAPI.setSignDocumentInterface('SignDocumentInterfaceDefault', onSuccess, onError);

The default interface loads the encryption key mobbsign.key from the assets folder (Android) or the Resources folder (iOS). See Installation.

4. Listen to the events​

Register the listeners you need. The most important one delivers the signed document:

MobbSignAPI.setOnDocumentSignedListener((result) => {
// result.document: the signed PDF, base64-encoded
}, onError);

MobbSignAPI.setOnProcessEndListener(() => {
// The user has finished
}, onError);

MobbSignAPI.setOnErrorOccurredListener((error) => {
// An error has occurred
}, onError);

See all the events in Events.

5. Sign the document​

Call signDocument with the PDF encoded in base64. The signing interface opens:

MobbSignAPI.signDocument(base64Pdf, onSuccess, onError);

The user reads the document, taps Sign, draws their signature and confirms it. The signed document is delivered to onDocumentSigned.

Complete example​

document.addEventListener('deviceready', () => {
MobbSignAPI.initMobbSignWithLicense('YOUR_LICENSE_KEY', () => {
MobbSignAPI.setSignDocumentInterface('SignDocumentInterfaceDefault', () => {
MobbSignAPI.setOnDocumentSignedListener((result) => saveSignedPdf(result.document), console.error);
MobbSignAPI.signDocument(base64Pdf, console.log, console.error);
}, console.error);
}, console.error);
}, false);

Next step​

Follow the whole process in Events.