我已经为我的应用程序集成/实现了面部识别(本地身份验证)身份验证,除了面部识别提示警报窗口界面外,每件事情都运行良好.
它显示了一个圆角正方形,浅灰色背景和标题"面部ID".
应该为标题上方的空白区域设置什么.这是脸部ID图标的空间吗?如果是,那我该怎么设置呢?我已经尝试了LAContext和LAPolicy中的所有内容.
看看这个快照:
这是我的代码:
let laContext = LAContext()
var error: NSError?
let biometricsPolicy = LAPolicy.deviceOwnerAuthenticationWithBiometrics
if (laContext.canEvaluatePolicy(biometricsPolicy, error: &error)) {
if let laError = error {
print("laError - \(laError)")
return
}
var localizedReason = "Unlock device"
if #available(iOS 11.0, *) {
switch laContext.biometryType {
case .faceID: localizedReason = "Unlock using Face ID"; print("FaceId support")
case .touchID: localizedReason = "Unlock using Touch ID"; print("TouchId support")
case .none: print("No Biometric support")
}
} else {
// Fallback on earlier versions …Run Code Online (Sandbox Code Playgroud) 我继承了一个代码库,其中包含以下类,提供对 Face/Touch ID 的支持。
预期的行为是,在 Face/Touch ID 成功后,用户就会登录。这是有效的。
但是,如果用户未能通过 Face ID 并选择输入密码,则一旦调用完成处理程序,他们就会退出。我相信选择使用密码会触发
else {
self.authState = .unauthenticated
completion(.unauthenticated)
}
Run Code Online (Sandbox Code Playgroud)
如何触发密码提示?我应该使用它来创建第二个策略LAPolicy.deviceOwnerAuthentication并对其进行评估吗?
import LocalAuthentication
public enum AuthenticationState {
case unknown
case authenticated
case unauthenticated
public func isAuthenticated() -> Bool {
return self == .authenticated
}
}
public protocol TouchIDAuthenticatorType {
var authState: AuthenticationState { get }
func authenticate(reason: String, completion: @escaping (AuthenticationState) -> Void) -> Void
func removeAuthentication() -> Void
}
public protocol LAContextType: class {
func canEvaluatePolicy(_ policy: LAPolicy, …Run Code Online (Sandbox Code Playgroud)