Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

swift - Checking for Email Verification in background

I want my swift App to check if the Email Adress is verified, but on the "waiting screen" are buttons, that won't work, when performing a while loop with the request. How can I solve this? I already tried by dispatchingQueue, but unfortunately you cannot do performSegue on another Thread.

class VerifyEmailViewController: UIViewController {

@IBOutlet weak var mailgif: FLAnimatedImageView!


@IBOutlet weak var Restart: UIButton!


@IBAction func ResendMail(_ sender: Any) {
    
    Auth.auth().currentUser?.sendEmailVerification()
    
}

@IBAction func DeleteAccount(_ sender: Any) {
    Auth.auth().currentUser?.delete()
    performSegue(withIdentifier: "RestartSignUp", sender: nil)
}


override func viewDidAppear(_ animated: Bool) {
    
    if Auth.auth().currentUser?.isEmailVerified == true {
        
        performSegue(withIdentifier: "EmailVerified", sender: nil)
        
    }
    else{
    
    Auth.auth().currentUser?.sendEmailVerification { (error) in
      // ...
           print("check for email verified")
            while Auth.auth().currentUser?.isEmailVerified != true {
                Auth.auth().currentUser?.reload()
                sleep(3)
            }
            print("Performing Segue")
            self.performSegue(withIdentifier: "EmailVerified", sender: nil)

                
            
        }
    }
}

override func viewDidLoad() {
   

       

    
    
    
    super.viewDidLoad()
    }
}
question from:https://stackoverflow.com/questions/66061222/checking-for-email-verification-in-background

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...