Ios 是否可以询问用户';在他看到UIView之前,他的PIN、面部ID或触摸ID?
我想为所有人锁定应用程序的历史记录部分,除了手机所有者。我不喜欢强迫用户只为这个应用创建帐户或新PIN。我可以授权使用他已设置的PIN、面部ID或触摸ID吗?框架将处理此问题 这是苹果的一部分: 框架将处理这个问题 这是苹果的一部分:Ios 是否可以询问用户';在他看到UIView之前,他的PIN、面部ID或触摸ID?,ios,objective-c,iphone,Ios,Objective C,Iphone,我想为所有人锁定应用程序的历史记录部分,除了手机所有者。我不喜欢强迫用户只为这个应用创建帐户或新PIN。我可以授权使用他已设置的PIN、面部ID或触摸ID吗?框架将处理此问题 这是苹果的一部分: 框架将处理这个问题 这是苹果的一部分: 对使用本地身份验证框架。如果您可以通过链接或其他方式回答此问题,我将接受。是。使用本地身份验证框架。如果您可以通过链接或其他方式回答此问题,我将接受它。 /// Logs out or attempts to log in when the user taps t
对使用本地身份验证框架。如果您可以通过链接或其他方式回答此问题,我将接受。是。使用本地身份验证框架。如果您可以通过链接或其他方式回答此问题,我将接受它。
/// Logs out or attempts to log in when the user taps the button.
@IBAction func tapButton(_ sender: UIButton) {
if state == .loggedin {
// Log out immediately.
state = .loggedout
} else {
// Get a fresh context for each login. If you use the same context on multiple attempts
// (by commenting out the next line), then a previously successful authentication
// causes the next policy evaluation to succeed without testing biometry again.
// That's usually not what you want.
context = LAContext()
context.localizedCancelTitle = "Enter Username/Password"
// First check if we have the needed hardware support.
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) {
let reason = "Log in to your account"
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in
if success {
// Move to the main thread because a state update triggers UI changes.
DispatchQueue.main.async { [unowned self] in
self.state = .loggedin
}
} else {
print(error?.localizedDescription ?? "Failed to authenticate")
// Fall back to a asking for username and password.
// ...
}
}
} else {
print(error?.localizedDescription ?? "Can't evaluate policy")
// Fall back to a asking for username and password.
// ...
}
}
}