我正在尝试使用 Firebase 实施电子邮件验证。我已经创建了成功重定向到我的应用程序的动态链接。我也在网上测试了该链接。它工作完美并且可以验证电子邮件。但是,验证电子邮件上的链接将我重定向到我的应用程序,Auth.auth().currentUser.isEmailVerified 仍然给我 false,即使我事先运行了 Auth.auth().currentUser?.reload() 命令。
对此有什么帮助吗?
您可以像这样设置计时器:
var verificationTimer : Timer = Timer() // Timer's Global declaration
self.verificationTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(LoginViewController.checkIfTheEmailIsVerified) , userInfo: nil, repeats: true)
然后使用此函数重复检查用户的当前状态:
func checkIfTheEmailIsVerified(){
FIRAuth.auth()?.currentUser?.reload(completion: { (err) in
if err == nil{
if FIRAuth.auth()!.currentUser!.isEmailVerified{
let feedVCScene = self.navigationController?.storyboard?.instantiateViewController(withIdentifier: "ViewControllerVC_ID") as! ViewController
self.verificationTimer.invalidate() //Kill the timer
self.navigationController?.pushViewController(feedVCScene, animated: true)
// Segueing to the next view(i prefer the instantiation method).
} else {
print("It aint verified yet")
}
} else {
print(err?.localizedDescription)
}
})
}
希望这可以帮助 :)
Source: https://stackoverflow.com/a/40037547/6596799
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)