0

I'm using Digits - by Twitter API for phone number verification, a quick scenario: user tap on Sign Up buttonex: 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:

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 !

Hussein
  • 487
  • 6
  • 22

1 Answers1

0

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)
   }