Customizing the behavior when the component is not installed
On the article Get started, we saw that the init()
code must be called before any other method is called:
pki.init(onWebPkiReady);
This method checks that the following conditions hold:
- The client is using a browser that is supported (click here for a list of supported browsers);
- All the necessary components are installed;
- The components are up-to-date.
If everything looks good, the given callback is called. However, if one of the above conditions is not held, the user is redirected to the installation page in a specific way so that, once the installation is completed, the user is redirected to the original page.
It is however possible to customize that behavior. For instance, you might want to display a message to the user explaining the problem and informing him that he
will be redirected to the installation page before actually doing so. In order to do that, you must use the extensive syntax of the init()
method (refer to the
method's documentation for further details) and pass a callback on the notInstalled
argument.
pki.init({
ready: onWebPkiReady,
notInstalled: onWebPkiNotInstalled
});
function onWebPkiNotInstalled (status, message) {
alert(message + '\n\nYou will be redirected to the installation page.');
pki.redirectToInstallPage();
}
Note
Although the argument is called notInstalled, the given callback is called whenever any of the 3 checked conditions are not held (the component is not installed, outdated or the user is using an unsupported browser).
At some point you should redirect the user to the installation page. In order to do that, call the redirectToInstallPage()
method, as shown above. For
more information about the arguments passed to the notInstalled
callback, please refer to the
method's documentation.