Empty diplayName value with SignIn with Apple
Step 2: Describe your environment
- Objective C or Swift: Swift
- iOS version: 14.5
- Firebase SDK version: 7.11.1 (SPM - latest)
- FirebaseUI version: master branche (SPM)
Step 3: Describe the problem:
Steps to reproduce:
- Install Firebase UI Auth
- Use Apple Sign In
- Try to get the displayName value of the Auth variable
Hi everyone,
I use the following code to allow the user to signup via email or Apple. When the user chooses Sign In with Apple the "displayName" property of the current user is empty. I only found a closed Issue where it was mentioned it was implemented.
So I'm curious if you have a tipp for me to get the displayName (name of the user) because I'm not allowed to request it again afterwards due to Apples guidelines.
Thank you!
@IBAction func LoginButtonTapped(_ sender: UIButton) {
if let authUI = FUIAuth.defaultAuthUI() {
authUI.providers = [
FUIEmailAuth(),
FUIOAuth.appleAuthProvider()
]
authUI.delegate = self
authUI.tosurl = URL(string: RCValues.sharedInstance.string(forKey: .termsOfServicesUrl))
authUI.privacyPolicyURL = URL(string: RCValues.sharedInstance.string(forKey: .privacyPolicyUrl))
let authViewController = authUI.authViewController()
self.present(authViewController, animated: true)
}
}
func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?) {
if authDataResult?.user != nil {
// Call user function to check user data and navigate the user to the next screen
_ = UserData()
}
}
In the UserData() I then try to access the displayName
if Auth.auth().currentUser != nil {
// This is empty with Apple Sign In (with Email it works)
print(Auth.auth().currentUser?.displayName)
self.userId = Auth.auth().currentUser?.uid
....
}
More context: See comment https://github.com/firebase/FirebaseUI-iOS/issues/886#issuecomment-839960979 and https://github.com/firebase/FirebaseUI-iOS/issues/886#issuecomment-840100136
Thank you for filing this issue; I've filed an internal issue b/189041707 to track this.
I'm also seeing this issue. Any update or ETA? Thanks!
A little more info on this issue to help narrow it down...
When I see the empty displayName issue I prompt for the user to enter a name and then use createProfileChangeRequest() to update the display name. This works and I can get the display name correctly from Auth.auth().currentUser UNTIL the user logs out.
Then on the next login the callback: authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?) ->authDataResult.user and Auth.auth().currentUser both have the displayName set correct (check right away on the callback) but then very shortly after (after the method has existed) Auth.auth().currentUser displayName is empty.
I'm seeing this with AppleId (using passcode sign-in (haven't tried face))
Display name is used extensively throughout my app so this issue is fairly critical for me :) If you don't think it will be fixed anytime soon please let us know so we can start the unfortunate work around (store and access the username from a local store instead of firebase auth).
Thanks!
@rosalyntan can you take a look at this? Seems to be an issue with upstream Firebase Auth if the name is disappearing after being set.
Any updates on this? I also have some users without names...
@rosalyntan any updates or ETA on this one? Thanks!
@morganchen12 @rosalyntan Any updates on this one? We have been waiting patiently :) Thanks!
Hello! This bug should be related (I think) to this one: https://github.com/firebase/firebase-ios-sdk/issues/4393 A workaround is available at the moment but if FirebaseUI is used we cannot implement it. Please not that this issue is currently REJECTING mobile apps who use Apple Sign In, so it should be prioritised. Thanks you
FWIW it looks like that firebase-ios-sdk bug has been closed now. Has anyone been able to verify that the FirebaseUI will automatically get this fix? Will it require a version increase?