Created
September 6, 2019 14:43
-
-
Save stupidly-logical/df6793bd87cb5019556432291e3a3fcc to your computer and use it in GitHub Desktop.
Safely signing out using FirebaseAuth in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment