NativeScript Firebase 已经初始化

NativeScript Firebase already initialized

我在我的应用程序中使用 Firebase,我注意到当我主动进行更改并且 LiveSync 更新应用程序时,它有时会显示 "firebase.init error: Firebase already initialized"。当更改不会触发整个应用程序重新启动时(例如 html 文件),就会发生这种情况。它完全扰乱了我当前的身份验证状态并迫使我重新启动应用程序。

有什么方法可以发现或防止这种情况发生吗?我可以尝试为它制作一个演示应用程序,但我觉得这可能已经发生在某人身上了。

我只是在使用 app.component 文档中显示的标准 firebase.init,没有什么特别或不同的地方。

不要在 App.component 的 ngOninit 上使用,而是尝试在 app launch 事件上初始化 firebase。

applicationOn(launchEvent, (args: LaunchEventData) => {
    firebase.init({
   // Optionally pass in properties for database, authentication and cloud messaging,
  // see their respective docs.
  }).then(
function () {
  console.log("firebase.init done");
},
function (error) {
  console.log("firebase.init error: " + error);
}
 );
});