Ionic Storage在iOS上不起作用



设置不起作用。获取不起作用。 我什至无法在iOS上获得驱动程序名称。 调用"就绪"不起作用。 电话只是不回。 承诺没有兑现。 它就像一个虚空。

Android和Chrome上的Ionic Storage工作正常。

这些是我安装的插件:

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"

这是我如何使用它的想法。 请记住,我的代码在Android和Chrome上运行良好。

import { Storage } from '@ionic/storage';
this.platform.ready()
.then(()=>{
this.storage.ready()
.then(() => {
this.storage.get(name)
.then((value)=>{

我也使用捕获来捕获错误,但没有。 它只是死了。 "storage.ready"甚至不会返回。

在我的app.module.ts中,我在正确的位置有这些行:

import { IonicStorageModule } from '@ionic/storage';
IonicStorageModule.forRoot(),

有什么想法吗? 我的头撞在墙上很痛。

我遇到了类似的问题。测试 .ts 中发生的情况

      this.storageEngine = localStorage.storage.driver;

然后在您的 HTML 文件中

        {{ storageEngine }}

我怀疑问题是,它试图使用indexeddb,在移动设备上使用sqlite来防止垃圾收集擦除您的数据。

第 1 步:

ionic cordova plugin add cordova-sqlite-storage

第 2 步:app.module.ts

IonicStorageModule.forRoot({
  name: '__yourapp-localstorage',
     driverOrder: ['sqlite','indexeddb', 'websql']
}),

最新更新