Redturbo Redturbo - 1 month ago 7
AngularJS Question

Define SSLCertificateChecker-PhoneGap-Plugin in ionic

How to define SSLCertificateChecker-PhoneGap-Plugin in ionic, I just installed the plugin using


ionic plugin add SSLCertificateChecker-PhoneGap-Plugin


but after running this code :

window.plugins.sslCertificateChecker.check(
successCallback,
errorCallback,
server,
fingerprint);

function successCallback(message) {
console.log(message);
// Message is always: CONNECTION_SECURE.
// Now do something with the trusted server.
}

function errorCallback(message) {
console.log(message);
}


this error was showed :


Cannot read property 'sslCertificateChecker' of undefined


I try to define 'sslCertificateChecker' in angular module like this :

var app = angular.module('juruparkir', ['ionic', 'ngCordova', 'sslCertificateChecker'])


but after run, this error was showed :


Error: [$injector:modulerr] Failed to instantiate module
sslCertificateChecker due to: Error: [$injector:nomod] Module
'sslCertificateChecker' is not available! You either misspelled the
module name or forgot to load it. If registering a module ensure that
you specify the dependencies as the second argument.


anybody can help ?

Answer

Finnaly I found the answer by myself, after install using

ionic plugin add SSLCertificateChecker-PhoneGap-Plugin

don't forget to add :

<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src  'self' 'unsafe-inline' *">

in index.html, after that this code should work :

window.plugins.sslCertificateChecker.check(
          successCallback,
          errorCallback,
          server,
          fingerprint);

     function successCallback(message) {
       console.log(message);
       // Message is always: CONNECTION_SECURE.
       // Now do something with the trusted server.
     }

     function errorCallback(message) {
       console.log(message);
     }
Comments