gpt4 book ai didi

ios - 未捕获的异常 'InvalidPathValidation',原因 : '(child:) Must be a non-empty string and not contain ' .' ' #' ' $' ' [' or ' ]''

转载 作者:行者123 更新时间:2023-11-28 06:00:03 25 4
gpt4 key购买 nike

我正在为我的应用程序进行身份验证,但在我点击注册按钮时收到错误“invalidPathValidation”。

根据我的研究,我认为这与 Firebase 不接受的电子邮件中的字符有关。

@IBAction func signUpButtonPressed(_ sender: Any) {
guard emailAddress.text != "" , password.text != ""
else {
errorOutlet.isHidden = false
return errorOutlet.text = "Email or Password field is empty."
}

if password.text != "" , emailAddress.text != "" {
Auth.auth().createUser(withEmail: emailAddress.text! , password: password.text!, completion: { (user, error) in
if let error = error {
print(error.localizedDescription)
self.errorOutlet.isHidden = false
return self.errorOutlet.text = "couldn't create account"
}

if let user = user {
let changeRequest = Auth.auth().currentUser!.createProfileChangeRequest()
changeRequest.displayName = self.firstName.text!
changeRequest.commitChanges(completion: nil)

let imageRef = self.userStorage.child("\(user.uid).jpg")
let data = UIImageJPEGRepresentation(self.profileImage.image!, 0.6)
let uploadTask = imageRef.putData(data! , metadata: nil, completion: { (metadata, err) in
if err != nil {
print(err!.localizedDescription)

// an err occured
self.errorOutlet.isHidden = false
return self.errorOutlet.text = "error"
}

imageRef.downloadURL(completion: { (url , er) in
if er != nil{
print(er!.localizedDescription)

// an error occured
self.errorOutlet.text = "error"
return self.errorOutlet.isHidden = false

}

if let url = url {
let userInfo : [String : Any] = ["uid" : user.uid ,
"first Name" : self.firstName.text! ,
"last name" : self.surName.text! ,
"urlToImage" :url.absoluteString]

self.ref.child("users").child("user.uid").setValue(userInfo)

let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "subscribe")
self.present(vc, animated: true, completion: nil)
}
})
})

uploadTask.resume()
}
})
}
}

最佳答案

这行好像有问题:

self.ref.child("users").child("user.uid").setValue(userInfo)

您将子“user.uid”视为字符串(其中包括有问题的“.”,它不能用作键)。

相反,使用没有“.”的 userInfo.uid。

关于ios - 未捕获的异常 'InvalidPathValidation',原因 : '(child:) Must be a non-empty string and not contain ' .' ' #' ' $' ' [' or ' ]'' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50093235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com