Skip to content

Firebase Authentication authStateChange listener has not been called after app comes from background mode #559

Closed Answered by robingenz
okletstryit asked this question in Q&A
Discussion options

You must be logged in to vote

Besides that, you need to call getCurrentUser(...) when using livereload because the listener fires only at the first start (because the native listener is only added once). This is the code i'm using for https://ionstarter.dev/:

private async addListeners(): Promise<void> {
  if (Capacitor.isNativePlatform()) {
    await this.removeAllListeners();
    // This fires every time the auth state changes
    // and once after the (native) listener is added.
    await FirebaseAuthentication.addListener('authStateChange', event => {
      this.ngZone.run(() => {
        this.authStateChangeSubject.next(event);
      });
    });
    // When using live reload, the auth state change
    // listener…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@robingenz
Comment options

Answer selected by okletstryit
@okletstryit
Comment options

@robingenz
Comment options

@okletstryit
Comment options

@robingenz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants