Reputation: 1949
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.
Upvotes: 0
Views: 1669
Reputation: 586
Ive come across similar issues. To test whats going on in your .ts
this.storageEngine = localStorage.storage.driver;
And then in your HTML file
{{ storageEngine }}
What I suspect the issue is, its trying to use indexeddb, use sqlite on mobile devices to prevent garbage collection from wiping your data.
Step 1:
ionic cordova plugin add cordova-sqlite-storage
Step 2: app.module.ts
IonicStorageModule.forRoot({
name: '__yourapp-localstorage',
driverOrder: ['sqlite','indexeddb', 'websql']
}),
Upvotes: 1