Securestorage error

I am testing my app in the browser and keep getting cordova_not_available for using it. The documentation states that a browser would use plain text local storage for mockup. Seems to fail for me or I am doing something wrong…

import { SecureStorage, SecureStorageObject } from '@ionic-native/secure-storage';


ionViewDidEnter() {
    this._platform.ready().then(() => {

      const aStorage = new SecureStorage();

      aStorage.create('MyStorage').then((storageObject : SecureStorageObject) => {
       }).catch((exception : String) => {
        if(exception == 'cordova_not_available'){
          console.log('Cordova failed!');

Chrome 60.0.3112.101 on Mac
Ionic 3.9.2
SecureStorage @latest

This doesn’t look right. Typically, ionic-native things are injected, not explicitly instantiated.

1 Like

Fixed it to

constructor(public navCtrl: NavController,
              private geolocation : Geolocation,
              private _platform : Platform,
              private _userService : UserService,
              private _storageConnection : SecureStorage,
              private loadingController:LoadingController,
              private alertCtrl: AlertController) {


            this._storageConnection.create('MyStorage').then((storageObject : SecureStorageObject) => {


But still getting the same error

What happened to the old ionic2 storage? That’s what I have been using…

Follow the code examples that are given in the docs. I don’t know where you got this example from, but follow official examples. Blog posts and tutorials can go out of date fast.

1 Like

I tried to create an instance of SecureStorageObject to circumvent the unnecessarily complicated two wrapped promises as it is shown in the tutorial. So I thought to keep only the SecureStorageObject as private attribute and work with that instead of opening the storage every time I want to write to it… Seems it does not work and I’ll have to stick to the tutorial…

It’s still around. The docs are in a section of their own, not in Native. Maybe that’s why you can’t find it?

Could be. Do you have a link?
I think I will try with secure storage though because it seems to be the standard go to solution now…

I’m not convinced of this. I think anything you store on device you should expect anybody with physical access to it can read, and design accordingly.

Sure, I don’t think it’s secure, but I thought it was the standard because this is the only storage tool featured in the ionic-native chapter…

Ionic-storage has its own chapter.

Dang, of course! I must be blind :crazy_face: this is where I had it from previously… :smile:
Thank you!