当我从另一个视图中解雇时,触摸Id自动触发成功

时间:2017-07-13 16:26:49

标签: ios swift swift3 touch-id

过程是: 1用户使用触摸ID登录 2用户注销(注销解除登录)   然后应用程序自动触发器触摸ID与成功响应(这不会发生在模拟器中)HELP !!

这是我在登录viewcontroller上的监听器

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)      

    if authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) && DataContainerSingleton.sharedDataContainer.fingerPrintEnabled == "SI"{
        self.touchIdListener()
    }


}

  func touchIdListener(){
    authenticationContext.evaluatePolicy(
        .deviceOwnerAuthenticationWithBiometrics,
        localizedReason: self.valFromCurrentLanguaje(valor: "LOGIN_FINGER_MSG"),
        reply: { [unowned self] (success, error) -> Void in

            if( success ) {
                let keychain = KeychainSwift()
                let data = keychain.get(Constants.USER_KEY)?.components(separatedBy: ",")
                DispatchQueue.main.async {
                    self.showProgress(text: Constants.EMPTY_STRING)
                }
                self.fromTouchId = true
                self.loginBL.startLogin(email: (data?[0])!, password: data?[1])
            }else {
                // Check if there is an error
                if let error = error {
                    print("\(error.localizedDescription)")

                }

            }

    })
}

1 个答案:

答案 0 :(得分:0)

所以解决方案是改变解雇

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

用于新实例

var storyboard = UIStoryboard()
            let vc : LoginViewController
            if (Constants.IS_IPAD) {
                storyboard = UIStoryboard.init(name: "LoginIpad", bundle: nil)
                vc = storyboard.instantiateViewController(withIdentifier: "ipadViewController") as! LoginViewController
            } else {
                storyboard = UIStoryboard.init(name: "Login", bundle: nil)
                vc = storyboard.instantiateViewController(withIdentifier: "iphoneViewController") as! LoginViewController
            }
            let navigationController = UINavigationController(rootViewController: vc)
            self.present(navigationController, animated: true, completion: nil)