在 ionic 中定义 SSLCertificateChecker-PhoneGap-Plugin
Define SSLCertificateChecker-PhoneGap-Plugin in ionic
如何在 ionic 中定义 SSLCertificateChecker-PhoneGap-Plugin,我刚刚使用
安装了插件
ionic plugin add SSLCertificateChecker-PhoneGap-Plugin
但在 运行 宁这个代码之后:
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);
}
显示此错误:
Cannot read property 'sslCertificateChecker' of undefined
我尝试像这样在 angular 模块中定义 'sslCertificateChecker' :
var app = angular.module('juruparkir', ['ionic', 'ngCordova', 'sslCertificateChecker'])
但是在运行之后,出现了这个错误:
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.
有人可以帮忙吗?
最后我自己找到了答案,安装后使用
ionic plugin add SSLCertificateChecker-PhoneGap-Plugin
别忘了补充:
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *">
在 index.html 之后,这段代码应该可以工作了:
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);
}
如何在 ionic 中定义 SSLCertificateChecker-PhoneGap-Plugin,我刚刚使用
安装了插件ionic plugin add SSLCertificateChecker-PhoneGap-Plugin
但在 运行 宁这个代码之后:
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);
}
显示此错误:
Cannot read property 'sslCertificateChecker' of undefined
我尝试像这样在 angular 模块中定义 'sslCertificateChecker' :
var app = angular.module('juruparkir', ['ionic', 'ngCordova', 'sslCertificateChecker'])
但是在运行之后,出现了这个错误:
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.
有人可以帮忙吗?
最后我自己找到了答案,安装后使用
ionic plugin add SSLCertificateChecker-PhoneGap-Plugin
别忘了补充:
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *">
在 index.html 之后,这段代码应该可以工作了:
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);
}