Within the Android app I create an anonymous user, and later migrate this user's data to a Google/Facebook auth account when the user decides to sign-in.
This has been working fine until using the FirebaseAuth updateProfile() method, whereafter the user is no longer anonymous when you call the isAnonymous() method.
From the Firebase API docs - https://developers.google.com/android/reference/com/google/firebase/auth/FirebaseUser.html#isAnonymous() :
isAnonymous():
Returns true if the user is anonymous; that is, the user account was created with signInAnonymously() and has not been linked to another account with linkWithCredential(AuthCredential).
FirebaseUser updateProfile() method:
FirebaseAuth.getInstance().currentUser?.updateProfile(
UserProfileChangeRequest.Builder()
.setDisplayName("Anonymous User")
.build())
The above method is called so that later in the app I can check the anonymous user's display name and write it to the database etc.
According to the API docs a user is considered anonymous until such stage that linkWithCredential() is called or the user signs in with an auth provider method, so why does the updateProfile() method make the anonymous user no longer anonymous?
What does Firebase auth () CurrentUser return? If a user isn't signed in, CurrentUser returns null. Note: CurrentUser might also return null because the auth object has not finished initializing.
If you'd like to sign the user out of their current authentication state, call the signOut method: import auth from '@react-native-firebase/auth'; auth() . signOut() .
var user = firebase. auth(). currentUser; if (user) { // User is signed in. } else { // No user is signed in. }
You can use Firebase Authentication to create and use temporary anonymous accounts to authenticate with Firebase. These temporary anonymous accounts can be used to allow users who haven't yet signed up to your app to work with data protected by security rules.
firebaser here
This is a bug in the Firebase Android SDK. It's been there since version 9.0 was launched around I/O 2016. Now that we know about it, it will be fixed in an upcoming version (although I don't know which version that will be yet).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With