Search code examples
segue

Swift - Segue only after TouchID Authentication


Code with change root view controller:

let contexta:LAContext = LAContext()

        if contexta.canEvaluatePolicy(.deviceOwnerAuthentication, error: nil){
            contexta.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Please use TouchID") { (good, error) in
                if good{


                    DispatchQueue.main.async{
                    self.navigationController?.popViewController(animated: true)

                        self.dismiss(animated: true, completion: nil)


                        let appDelegate = UIApplication.shared.delegate! as! AppDelegate

                        let initialViewController = self.storyboard!.instantiateViewController(withIdentifier: "myTabbarControllerID")
                        appDelegate.window?.rootViewController = initialViewController
                        appDelegate.window?.makeKeyAndVisible()
                    }

Code is working with an issue regarding the AppDelegate.


Solution

  • Turns out it code in the AppDelegate that kept loading the login screen. Thank you for the help!