in

Set user display name not working Firebase


I’m getting a pretty strange error when trying to set the .displayName property within my IOS project. Here is my code:

if Auth.auth().currentUser != nil {
                let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
                if (changeRequest == nil){
                    self.errorLabel.text = "Something went wrong"
                    self.errorLabel.alpha = 1
                    return
                }
                
                changeRequest?.displayName = usernameText
                changeRequest?.commitChanges { error in
                    if (error != nil){
                        print("here")
                        self.errorLabel.text = "Something went wrong"
                        self.errorLabel.alpha = 1
                        return
                    }else{
                        print(Auth.auth().currentUser?.displayName as Any)
                    }
                }
            } else {
                self.errorLabel.text = "Something went wrong"
                self.errorLabel.alpha = 1
                return
            }

The line print(Auth.auth().currentUser?.displayName as Any) does not even seem to run and checking the .displayName property later on returns nil. Is .commitChanges not working or is it something else?

Thank you!



Source: https://stackoverflow.com/questions/70552950/set-user-display-name-not-working-firebase

A versatile library for building CLI applications in Golang

Accessing GCP Redis from a service within Kubernetes (istio)