Secure Storage fails to load keys


Hi there

Our app is using the secure storage for saving session tokens and so on.
It did work previously on Android and it is still working properly on iOS.

But now, whenever I want to try to set a key value pair, the plugin throws an error, that it can’t load the key.

Failed to load key for

First I thought that I did something wrong with the promise handling. But after testing with the code beneath, I’m pretty sure that isn’t the case.

Code that fails:

checkDeviceSecure() : Promise<any> {  
        return new Promise((resolve, reject) => {
            this._ss.create('my-storage').then(ss => {
                this._storage = s;

                this._storage.set("OMG", "WOOPWOOP").then(() => {
                    console.log('SET DID WORK');
                }).catch(error => {
                    console.log(`SET DOES NOT WORK: ${error}`)

            }).catch(err => {
                //error if device not secure

It always ends up in the log SET DOES NOT WORK.

When I looked at the errors received in the secure storage native wrapper (securestorage.js - _executeNativeMethod - lines 58 to 73 ), I always, before any other error occurs, got three times a JSON Error. No additional info on that…

Does anyone have an idea, what the problem may be?

My environment:


   ionic (Ionic CLI)  : 4.8.0 (/Users/si1/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1


   cordova (Cordova CLI) : 7.1.0
   Cordova Platforms     : android 7.1.1, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 11 other plugins)


   ios-deploy : 1.9.2
   NodeJS     : v8.9.4 (/Users/si1/.nvm/versions/node/v8.9.4/bin/node)
   npm        : 6.9.0
   OS         : macOS Mojave
   Xcode      : Xcode 10.2 Build version 10E125

Ionic Native:

"@ionic-native/secure-storage": {
      "version": "4.18.0",
      "resolved": "",
      "integrity": ...

Cordova Plugin:

cordova-plugin-secure-storage 2.6.8 "SecureStorage"

Thanks for the help :slight_smile:


More information:

I updated the secure storage native plugin to version 4.20.0, and the cordova plugin to version 3.0.1.
Now I get the following error :


Temporary fix:

Downgrade ionic-native/secure-storage to version: 4.18.0
Downgrade cordova-plugin-secure-storage to version: 2.6.7

Another problem still remains (not mentioned in posts above):

On first startup of the app (directly after installation), the create() function of the secure storage does neither return an error or a success. Nothing happens.