1
我一直在努力完成這項工作,但isEmailVerified
不斷返回false ...甚至認爲我明確驗證了電子郵件。Swift Firebase電子郵件驗證總是返回false
用戶創建
FIRAuth.auth()?.createUser(withEmail: Email.text!, password: Password.text!) { (user:FIRUser?, error:Error?) in
if error == nil {
let when = DispatchTime.now() + 1
DispatchQueue.main.asyncAfter(deadline: when) {
FIRAuth.auth()?.currentUser?.sendEmailVerification(completion: { (error) in
let post2 = UIAlertController(title: "Verification sent", message: "A Email will be sent to activate your account.", preferredStyle: .alert)
post2.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
self.performSegue(withIdentifier: "Sign_in", sender: nil)
}))
self.present(post2, animated: true, completion: nil)
})
}
} else {
self.ErrorMsg.isHidden = false
self.Password.text = ""
print(error.debugDescription)
}
}
用戶驗證
FIRAuth.auth()?.addStateDidChangeListener { auth, user in
if let user = user {
Shared.shared.User_ID = user.uid
Shared.shared.User_Email = user.email
if user.isEmailVerified {
// Email Verified
self.performSegue(withIdentifier: "Launch_L", sender: nil)
} else {
self.logOut.isHidden = false
}
} else {
self.performSegue(withIdentifier: "Launch_S", sender: nil)
}
}
提前感謝您的幫助!
你有沒有想出解決辦法? – cyril
@cyril yup我聯繫了支持,在檢查用戶是否驗證之前,我需要把'FIRAuth.auth()?。currentUser?.reload()' –