Answer the question
In order to leave comments, you need to log in
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)
}
}
}
}
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)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question