Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android firebase auth state listener called multiple times

I am using Firebase android sdk v.9.0.2 and can't get past the registration for now. I am adding an auth state listener and removing it on successful registration. Yet it is called multiple times. This is what i'm getting in my logs:

D/FirebaseAuth: Notifying listeners about a sign-out event.
D/FirebaseApp: Notifying auth state listeners.
D/FirebaseApp: Notified 0 auth state listeners.
D/ActivityRegister: auth listener called
D/FirebaseAuth: Notifying listeners about user ( bwVX8jBbZvYcIj28hYsGZCcbzxi1 ).
D/FirebaseApp: Notifying auth state listeners.
D/FirebaseApp: Notified 0 auth state listeners.
D/ActivityRegister: auth listener called
D/FirebaseAuth: Notifying listeners about user ( bwVX8jBbZvYcIj28hYsGZCcbzxi1 ).
D/FirebaseApp: Notifying auth state listeners.
D/FirebaseApp: Notified 1 auth state listeners.

The "D/ActivityRegister: auth listener called" log is inside the listener iteself. As you can see, when Firebase notifies 0 listeners, it is actually called. And when it shows 1 listener, the listener doesn't get called at all. Is there any workaround for this?

like image 629
Євген Гарастович Avatar asked Jun 10 '16 07:06

Євген Гарастович


2 Answers

Fixes are not expected. That closed issue. https://github.com/firebase/quickstart-android/issues/80

like image 169
Sergey Aleynik Avatar answered Sep 20 '22 22:09

Sergey Aleynik


You can find when this method is triggered here:

Firebase Reference - AuthStateListener

I handle this function trigger with an switch and only use the "Login_Attempt" and "Register_Attempt" (to send verification email) cases ignoring the rest of them. Just create a String variable (and i.e. when user clics Sign_In button, set it as "Login_Attempt")

BR

like image 35
Pablo Prado Avatar answered Sep 22 '22 22:09

Pablo Prado