FirebaseUI-iOS
FirebaseUI-iOS copied to clipboard
Auth.auth().currentUser.isAnonymous is not correctly updated after linking Apple Login
Step 2: Describe your environment
- Objective C or Swift: Swift
- iOS version: 13.3
- Firebase SDK version: 6.6.2
- FirebaseUI version: 8.4.1
- CocoaPods Version: 1.8.4
Step 3: Describe the problem:
When migrating an anonymous user to a non-anonymous one by choosing the Login with Apple ID, the Auth.auth().currentUser.isAnonymous
isn't updated and the attribute remains false.
Steps to reproduce:
- (Programatically) log in with an anonymous user
- Open the Firebase UI login screen with
authUI.shouldAutoUpgradeAnonymousUsers = true
- Log in with an Apple ID
- Listen for the callback in
func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?)
Observed Results:
-
Auth.auth().currentUser.isAnonymous
is still true -
authDataResult?.user.isAnonymous
is false
Expected Results:
-
Auth.auth().currentUser.isAnonymous
has the same value as the user provided in the callback parameter, i.e. it's false
Further notes
- When using other login methods, the two values are correctly synced.
- There used to be a similar issue (#651) for the email login.
- Not sure, whether this is a Firebase UI issue or a Firebase (Auth) issue in general.
I haven't tested this myself, but I'm planning to support anonymous users and apple sign-in, so this would be a high priority request for myself as well. I'll comment again if I see the same issue.
I've filed a bug internally as b/160627975.
@joeljfischer This bug is about Auth.auth().currentUser.isAnonymous
not being updated. However, linking an anon user with Apple Sign-in still works fine (minus this bug).
As OP mentioned, you just need to use authDataResult?.user.isAnonymous
instead of Auth.auth().currentUser.isAnonymous
for now to detect if a user has been upgraded or not for now. This workaround should be temporary and will not need be needed once we fix the bug.
@yuchenshi Thank you for the clarification.