我检查了用户是否通过电子邮件验证,但是无论我发送和确认多少封电子邮件,验证状态仍然为false
。我在检查时做错了什么吗?
FIRAuth.auth()?.addStateDidChangeListener({ (auth, user) in
if (auth.currentUser?.isEmailVerified)!{
let mainStoryboard: UIStoryboard = UIStoryboard(name:"Main",bundle:nil)
let NewPostViewController: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "NewPostViewController")
//Send the user to the LoginViewController
self.present(NewPostViewController, animated: true, completion: nil)
}else{
let alertVC = UIAlertController(title: "Error", message: "Sorry. Your email address has not yet been verified. Do you want us to send another verification email to \(self.currentUser.generalDetails.email).", preferredStyle: .alert)
let alertActionOkay = UIAlertAction(title: "Okay", style: .default) {
(_) in
FIRAuth.auth()?.currentUser?.sendEmailVerification(completion: nil)
}
let alertActionCancel = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alertVC.addAction(alertActionOkay)
alertVC.addAction(alertActionCancel)
self.present(alertVC, animated: true, completion: nil)
}
})
reloadWithCompletion
也听起来很有前途。 - Frank van Puffelen