更新时间:2023-12-01 17:58:52
一个 NSTimer
,时间间隔将检查用户是否已经过验证,然后在验证完成后终止计时器。
How i implemented this feature was to add a NSTimer
, with time interval which would check if the user has been verified and then terminate the timer when the verification was done.
var verificationTimer : Timer = Timer() // Timer's Global declaration
self.verificationTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(LoginViewController.checkIfTheEmailIsVerified) , userInfo: nil, repeats: true)
函数检查您当前的用户状态: -
Function to check your current user state:-
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)
}
})
}