E
E
Emil2021-06-15 19:14:56
Swift
Emil, 2021-06-15 19:14:56

How to get username from FireBase?

Hello! Please tell me guys. I'm trying to get a username from FIreBase. But nothing comes out, despite the fact that the email is quietly returned.
I register:

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        let email = EmailField.text!
        let nickName = NickNameField.text!
        let pass = Password.text!
        if(signup) {
            if(!email.isEmpty && !nickName.isEmpty && !pass.isEmpty) {
                Auth.auth().createUser(withEmail: email, password: pass) { Result, Error in
                    if Error == nil {
                        if let result = Result {
                            print("Успешная регистрация")
                            print(result.user.uid)
                            let ref = Database.database().reference().child("users")
                            ref.child(result.user.providerID).updateChildValues(["name" : nickName, "email" : email])
                            
                            
                            self.dismiss(animated: true, completion: nil)
                            
                        }
                    }
                }
            }

I get info:
func LoadingUserInf() {
        let user = Auth.auth().currentUser
        if let user = user {
          // The user's ID, unique to the Firebase project.
          // Do NOT use this value to authenticate with your backend server,
          // if you have one. Use getTokenWithCompletion:completion: instead.
          let uid = user.uid
          let email = user.email
          let photoURL = user.photoURL
          var multiFactorString = "MultiFactor: "
          for info in user.multiFactor.enrolledFactors {
            multiFactorString += info.displayName ?? "[DispayName]"
            multiFactorString += " "
          }
            NickNameLable.text = email
          // ...
        } else {
            print("Error")
            print(user)
        }

I receive email normally, but I can’t figure out how to get to certain parameters of the database.
How can I get certain data from the database by their names?
Thanks in advance to all who respond!
Base screenshot attached:
60c8d1ff369cf118412786.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question