【发布时间】:2017-10-24 16:31:10
【问题描述】:
我正在使用 Ionic 2 和 secureStorage 插件。问题在于,对于 Android,必须使用代码保护设备才能使用安全存储。
在它的文档中:
var ss;
var _init = function () {
ss = new cordova.plugins.SecureStorage(
function () {
console.log('OK');
},
function () {
navigator.notification.alert(
'Please enable the screen lock on your device. This app cannot operate securely without it.',
function () {
ss.secureDevice(
function () {
_init();
},
function () {
_init();
}
);
},
'Screen lock is disabled'
);
},
'my_app');
};
_init();
但是我使用的不是ionic 1,而是ionic 2。如何调用secureDevice方法?
我会做这样的事情:
this.secureStorage.create('myStorage')
.then((storage: SecureStorageObject) => {
storage.set('var', 'toto')
.then(
() => console.log('ok),
(e) => console.log('error');
);
}).catch((err) => {
console.error('The device is not secured');
})
我可以在锁中检测到设备未固定。但是如何在我的 console.err 旁边添加对 secureDevice 方法的调用?
【问题讨论】:
-
提出了ionic的问题,以防万一
标签: angular ionic-framework ionic2