I'm using Ionic 2 and the secureStorage plugin. The problem is that with Android, the device has to be secured with a code to use secure storage.
In the documentation it has:
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();
But I'm not using ionic 1 but ionic 2. How to call the secureDevice method?
I do anything like:
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');
})
I can detect in the catch that the device is not secured. But how can I add next to my console.err a call to the secureDevice method?
The documentation: https://ionicframework.com/docs/native/secure-storage/