ios - 当我从另一个 View 中退出时,Touch ID 自动触发成功

标签 ios swift swift3 touch-id

流程是: 1 用户使用touch id登录 2. 用户注销(logout Dismiss to Login) 然后应用程序自动触发触摸 ID 并成功响应(这不会在模拟器中发生)帮助!!

这是我在登录 View Controller 上的监听器

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

                }

            }

    })
}

最佳答案

所以解决方案是更改解雇

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)

关于ios - 当我从另一个 View 中退出时,Touch ID 自动触发成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45086336/

相关文章:

unit-testing - 快速单元测试 : HotSwap an CLLocationManager Object

ios - 如何注册用户的 ios 设备以从 AppDelegate 以外的地方接收推送消息?

core-data - Swift 3 中的 managedObjectContext

ios - 错误请求 Alamofire + Basic Auth

ios - SKAction.rotate 不起作用?

ubuntu - Ubuntu 上的 Swift : use of undeclared type 'NSFileHandle'

iphone - 为 CLLocationManger 区域画一个圆圈

iOS 快速从深层链接 URL 中提取固定链接

iOS * 单元性能 : Autolayout vs Frame?

objective-c - 遍历特定类型的所有 subview