简体   繁体   中英

How do I solve FirebaseAuth isAnonymous return false on an Anonymous user?

I logged in as Anonymous user. See my Firebase console screenshot:

在此处输入图像描述

But when I checked by printing the status like this:

print('Is Anonymous:
 ${FirebaseAuth.instance.currentUser.isAnonymous}. UID: ${FirebaseAuth.instance.currentUser.uid}');

This is what I got in debug console:

I/flutter (12139): Is Anonymous: false. UID: O75s04Y3voRTdqaUJJ5gdyinQSB3

How can it be? Is there anyone ever had this kind of problem and solved it?

I usually check the user.providerData to determine if the user is associated with any providers. If not, I consider it anonymous.

In another app I only care about Google sign-in, and use this:

bool isSignedInUser() {
  return this.user != null && (
    this.user.providerData.any((UserInfo info) => info.providerId == "google.com")
  );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM