【发布时间】:2021-03-25 11:54:21
【问题描述】:
我尝试使用 firebase 的 isNewUser 方法,但它一直返回 false。根据我阅读的内容,它仅适用于通过 Firebase 控制台创建的帐户,这就是我的情况。一旦用户点击“连接”并且他的信息是正确的,该函数就会被调用。
func sign_in_handler() {
if self.email != "" && self.pass != "" {
Auth.auth().signIn(withEmail: self.email, password: self.pass) { (result, error) in
if err != nil {
self.error = err!.localizedDescription
self.alert.toggle()
return
}
guard let isNew = res?.additionalUserInfo?.isNew else {return}
print("\nIs new user? \(isNew)\n")
if newUserStatus == true{
UserDefaults.standard.set(true, forKey: "status")
NotificationCenter.default.post(name: NSNotification.Name("status"), object: nil)
}
else{
UserDefaults.standard.set(true, forKey: "status")
NotificationCenter.default.post(name: NSNotification.Name("status"), object: nil)
}
}
} else {
self.error = "Wrong informations."
self.alert.toggle()
}
}
感谢您的帮助!
【问题讨论】:
标签: ios swift firebase firebase-authentication