Ionic Storage doesn't work on iOS

Setting doesn’t work. Getting doesn’t work. I can’t even get the driver name on iOS. Calling “ready” doesn’t work. The calls just don’t return. The promises go unfulfilled. It’s like a void out there.

Ionic Storage on Android and Chrome work fine.

These are the plugins I have installed:

cordova-plugin-device 1.1.4 "Device"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.2.1 "OneSignal Push Notifications"
cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-calendar 5.0.0 "Calendar"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-add-swift-support 1.7.0 "AddSwiftSupport"
cordova-plugin-ionic 2.0.4 "IonicCordova"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"

This is an idea of how I’m using it. Keep it mind that my code works great on Android and in Chrome.

import { Storage } from '@ionic/storage';

this.platform.ready()
.then(()=>{
this.storage.ready()
.then(() => {
this.storage.get(name)
.then((value)=>{

I am also using catches to catch errors, but there aren’t any. It just dies. “storage.ready” doesn’t even return.

In my app.module.ts, I have these lines in the right places:

import { IonicStorageModule } from '@ionic/storage';

IonicStorageModule.forRoot(),

Any ideas? My head hurts from banging it against the wall.

Please provide more useful infos, otherwise it’s hart to help you.

  1. provide ‘Ionic info’
  2. please show some code examples, where you wanna get the value from the storage
  3. On which plattform do you test? (browser, device, devapp ???)

regards,
Oliver

ionic info:

cli packages: (C:\Users\timk\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.11.3
    npm               : 3.10.10
    OS                : Windows 7

Environment Variables:

    ANDROID_HOME : D:\Program Files (x86)\Android\android-sdk

Misc:

    backend : pro

This is how I get a value from storage. It works great on Android and Chrome:

import { Platform } from 'ionic-angular';
import { Storage } from '@ionic/storage';

constructor(private storage:Storage, public platform: Platform) {
}

				this.platform.ready()
					.catch((error)=>{
						reject("Platform not ready: " + JSON.stringify(error));
					})
					.then(()=>{
						this.storage.ready()
							.catch((error)=>{
								reject("ReadyError: " + JSON.stringify(error));
							})
							.then(() => {
								this.storage.get(name)
									.then((value)=>{
										resolve(value);
									})
									.catch((error)=>{
										reject("GetError: " + JSON.stringify(error));
									});
							});
					});

My workstation is Windows 7. I also have an Android phone and an iPhone, on which I use both Ionic View and apps made with Ionic Pro, and also “ionic cordova run android --device”. I also use “ionic serve” in Chrome.

Thanks Catweazle101. I’m completely out of ideas. I even tried using NativeStorage instead, but that didn’t work either. Same problem on iOS.

Hmm…
I’m also a newbie in Ionic and it’s my first mobile application, which I’m working on…
I had also a few head bangers :slight_smile:

But I’m working in my project with the native-storage plugin without any problems.

I use following plugin:

cordova-sqlite-storage 2.1.4 "Cordova sqlite storage plugin"

I created a little wrapper-service around my storage-plugin.

An example, how I get and set the a token looks like this:

@Injectable()
export class StorageService {

    constructor(private storage: Storage) { }

    getToken(): Observable<string> {
        return Observable.fromPromise<string>(this.storage.get('token'));
    };

    saveToken(token:string): Promise<any> {
        return this.storage.set('token', token);
    };

I didn’t use the ready-promise as you see

and this works for me on Android and IOS

Where and how do you set the value for the storage?

P.S
These are my infos:

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v8.9.1
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Users/nameOfUser/Library/Android/sdk

Misc:

    backend : pro