【发布时间】:2021-07-09 06:25:23
【问题描述】:
我正在尝试使用设备密码对用户进行身份验证。我想直接查看密码板。但是使用下面的代码,我总是必须先通过生物特征认证并且失败才能使用密码进行认证。如何直接获取密码板?
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
}
}
}
}
}
谢谢
【问题讨论】:
-
检查这里:developer.apple.com/documentation/localauthentication/lapolicy/… 它说...
If biometry is available, enrolled, and not disabled, the system uses that first... -
我在下面找到并尝试了这种方法。它有点工作,但我不知道这些代码做了什么。 stackoverflow.com/questions/46723662/…
标签: ios swift authentication biometrics passcode