简体   繁体   中英

How to navigate to view controller after successful verification?

I'm using Digits - by Twitter API for phone number verification, a quick scenario: user tap on Sign Up button ex: LoginViewController -> Digits API initialize to verify his phone number -> after successfully verification the app should move to next View Controller ex: HomeViewController but what happens is when the user is successfully verified the app returns to previous which is LoginViewController ! here is my code:

LoginViewController

// MARK: - Sign Up Button
@IBAction func signUpPressed(_ sender: Any) {

    let configuration = DGTAuthenticationConfiguration(accountFields: .defaultOptionMask)

    configuration?.appearance = DGTAppearance()
    configuration?.appearance.backgroundColor = UIColor.white
    configuration?.appearance.accentColor = UIColor.red

    // Start the Digits authentication flow with the custom appearance.
    Digits.sharedInstance().authenticate(with: nil, configuration:configuration!) { (session, error) in
        if session != nil {

            //Print Data
            print(session?.phoneNumber!)
            print(session?.userID!)

            // Navigate to the main app screen to select a theme.
            self.performSegue(withIdentifier: "toSignUpVC", sender: self)

        } else {
            print("Error")
        }
    }

}

Example of Storyboard:

故事板

NOTE: after the App returns to LoginViewController I can go to SignUpViewController successfully after I tap the SignUp Button again, because Digits registered the device in the first time, so why doesn't Digits move to the next View Controller instead of going back to LoginViewController, any user will never know if he was successfully signed up or not !

You can fix your issue by adding the code below. Closure should be called after the function execution.

   let deadline = DispatchTime.now() + .seconds(1)
   DispatchQueue.main.asyncAfter(deadline: deadline)  
   {
    self.performSegue(withIdentifier: "toSignUpVC", sender: self)
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM