I checked if user is verified via email or not. However, no matter how many emails I sent and confirm, the verification status is still false
. Am I doing something wrong while checking it?
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)
}
})