我如何实现此功能的方法是添加一个 NSTimer
带有时间间隔的,它将检查用户是否已通过验证,然后在完成验证后终止计时器。
var verificationTimer : Timer = Timer() // Timer's Global declarationself.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) } })}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)