I'm trying to user Secure storage (https://ionicframework.com/docs/v2/native/secure-storage/) on Ionic application.
In my controller:
.controller('ExampleCtrl', function ($scope, SecureStorage) {
var ss = new SecureStorage(
function () {
console.log('Success')
},
function (error) {
console.log('Error ' + error);
},
'my_app');
var key = 'aaa';
ERROR:
ionic.bundle.js:26799 Error: [$injector:unpr] Unknown provider: SecureStorageProvider <- SecureStorage <- ExampleCtrl
But it don't know the SecureStorage provider.
Do you know what i'm doing wrong?
Please try this:
.controller('ExampleCtrl', function ($scope) {
var ss = new cordova.plugins.SecureStorage(
function () {
console.log('Success');
},
function (error) {
console.log('Error ' + error);
},
'my_app');
});
So, remove SecureStorage from the controller arguments and add cordova.plugins.
on the second line.
And don't forget to install the plugin (of course):
ionic plugin add cordova-plugin-secure-storage --save
Now you can use the functions on ss
, but don't use the documentation in the link you provided, since this is Ionic 2 documentation. Use the plugin documentation in stead: https://github.com/Crypho/cordova-plugin-secure-storage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With