3. Initialize the PluginApi instance
Once the PluginApi
instance has been created, it must be initialized.
The initialization verifies the presence of the native SignID software. If the native SignID software is missing, an error message will be displayed in which you will find a download link to retrieve the SignID software installer.
Note that the initialize
method, like almost all other methods, is async and returns a Promise
!
Also note that you can provide an extra configuration object to the initialize method. The one provided through the initialize method will be merged with the one that was used when retrieving the instance using the PluginApiFactory
(in step 2). This is entirely optional however.
To initialize the PluginApi instance, follow the example below:
'use strict'
import { PluginApi, PluginApiFactory, Exceptions } from 'connective-wrapper';
const pluginApi: PluginApi = pluginApiFactory.getInstance();
pluginApi.initialize({ activationToken: '....' })
.then(() => {
// good to go. PluginApi instance is initialized and the native SignID software was detected
})
.catch((e: Error) => {
if (e instanceof Exceptions.SoftwareRequiredException) {
console.error(`Native SignID software could not be detected. Download at ${e.downloadUrl}`);
} else if (e instanceof Exceptions.ActivationRequired) {
// no activation token was provided OR the provided one was not (or no longer) valid
}
});