我正在尝试使用设备密码对用户进行身份验证。我想直接查看密码板。但是使用下面的代码,我总是必须先通过生物特征认证并且失败才能使用密码进行认证。如何直接获取密码板?
import UIKit
import LocalAuthentication
class ViewController: UIViewController {
@IBOutlet weak var userButton: UIButton!
@IBOutlet weak var resultLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func buttonPressed(_ sender: UIButton) {
authenticateUser()
}
func authenticateUser() {
let context = LAContext()
context.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: "Please authenticate to proceed.") { (success, error) in
DispatchQueue.main.async {
if success {
self.resultLabel.text = "Success"
print("Success")
}else{
self.resultLabel.text = "Failed"
print("Failed")
return
}
}
}
}
}
谢谢