Ionic 3 / AngularFire2 authState不能在Android上保留(但可以在Web上运行)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ionic 3 / AngularFire2 authState不能在Android上保留(但可以在Web上运行)相关的知识,希望对你有一定的参考价值。

嘿所有这些让我疯狂。

这是代码:

  constructor(
    platform: Platform,
    statusBar: StatusBar,
    splashScreen: SplashScreen,
    afAuth: AngularFireAuth
  ) {
    afAuth.authState.subscribe(user => {
      if (user) {
        this.rootPage = "TabsPage";
        console.log("logging in");
        console.log(JSON.stringify(user)); // user
      } else {
        this.rootPage = "LoginPage";
        console.log("logging out");
        console.log(JSON.stringify(user)); // null
      }
    });

在网络上运行时,我可以登录我的应用程序,然后按预期注销。但是在android上(通过离子cordova运行android测试),用户订阅被设置,然后立即设置为null。

答案

所以我明白了!

这是我使用v4.12.1的firebase版本

我更改为版本4.11.0并且问题停止发生。

以上是关于Ionic 3 / AngularFire2 authState不能在Android上保留(但可以在Web上运行)的主要内容,如果未能解决你的问题,请参考以下文章