Firebase Auth, Android signout completely

//Declaration and defination private FirebaseAuth firebaseAuth; FirebaseAuth.AuthStateListener authStateListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { if (firebaseAuth.getCurrentUser() == null){ //Do anything here which needs to be done after signout is complete signOutComplete(); } else { } } }; //Init and attach firebaseAuth = FirebaseAuth.getInstance(); firebaseAuth.addAuthStateListener(authStateListener); //Call signOut() firebaseAuth.signOut();
It is observed that calling signOut() on a FirebaseAuth object and the updating the App state like, checking for FirebaseUser to be null deosn't give expected result. To solve this, authStateListener can be attached to the FirebaseAuth object which will listen to auth state changes and proceed once the user is null.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.