Ionic 4 IOS FIRESTORE内部声明失败:AsyncQueue已失败:在索引数据库服务器中遇到内部错误

时间:2019-08-10 15:45:04

标签: ios angular ionic-framework angularfire angularfire2-offline

我正在开发Ionic应用程序,正在将Firestore用作数据库,并使用离线模式。

import {AngularFirestoreModule} from '@ angular / fire / Firestore';
AngularFirestoreModule.enablePersistence (),

当我打开应用程序时,即使在脱机模式下,一切也都可以正常工作。 但是,如果应用程序在重新打开时保持在后台模式下打开,它将始终指示此错误:

  

FIRESTORE(6.2.4)内部声明失败:AsyncQueue已经存在   失败:在索引数据库中遇到内部错误   服务器。

而且我无法再导航到应用程序中的任何位置,因为我的条件是订阅一直有效,直到组件被销毁为止(这是在更改页面时发生的情况)

takeUntil (componentDestroyed (this)):

我收到以下错误:

  

“ 1退订期间发生了1个错误:1)错误:FIRESTORE(6.2.4)   内部声明失败:AsyncQueue已经失败:内部   索引数据库服务器中遇到错误“

完整的应用程序停止工作,不得不关闭并重新打开非常烦人。

有什么不同的方法吗?我已经看过StackOverflow,Github,所有的google,但找不到任何解决方案。 我所看到的其他应用程序,例如Netflix,HBO等,都可以。就是说,当您重新打开应用程序时,它并没有完全停留在原先的位置,它会警告您正在加载,完成加载后,它会使您非常接近离开应用程序之前的状态。我想它有一个背景和前景变化检测器以及每个事件的功能。

我当时以为离子周期可以解决这个问题,例如:  -检测到对后台的更改,然后退订,如果对前景进行任何更改,则重新订阅。

您还知道其他方式吗?

1 个答案:

答案 0 :(得分:0)

我解决的错误:

    window.onerror = function(error) {
  if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
    // Refresh the page to restore IndexedDb to a working state.
    window.location.reload();
  }
};

以及如何观察背景和前景的状态变化:

import { Platform } from 'ionic-angular';

@Component({
  template: `OK`
})

constructor(public platform: Platform) {

    platform.ready().then(() => {

      if (platform.is('cordova')){

        //Subscribe on pause
        this.platform.pause.subscribe(() => {
          //Hello pause
        });

        //Subscribe on resume
        this.platform.resume.subscribe(() => {
          window['paused'] = 0;
        });
       }
    });
}

希望他们能为您打招呼。