gpt4 book ai didi

ios - 如何知道是否启用了面容 ID

转载 作者:行者123 更新时间:2023-11-28 23:39:55 25 4
gpt4 key购买 nike

首先,为什么每个应用程序都“启用”了touch id而不是face id。因此,如果您设置了触摸 ID,则每个应用都可以使用它,但面容 ID 需要用户为每个应用接受它。

如何查找用户是否为我的应用启用了面容 ID。

这是我用来找出认证类型的代码

    let hasAuthenticationBiometrics = myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
let hasAuthentication = myContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: nil)

if #available(iOS 11.0, *) {
if hasAuthentication {
if hasAuthenticationBiometrics {
switch myContext.biometryType {
case .none: return .none
case .faceID: return .faceID // Find out if it is enabled
case .touchID: return .touchID
}
} else {
return .passcode
}
} else {
return .none
}
} else {
if hasAuthentication {
if hasAuthenticationBiometrics {
return .touchID
} else {
return .passcode
}
} else {
return .none
}
}

如果用户有面部识别码但在我的应用程序中禁用了它,即使我的应用程序使用密码进行了身份验证,我总是会得到他“有”面部识别码?

最佳答案

找到答案,你使用错误指针来找出用户是否禁用了面部识别。

    var error: NSError?
let hasAuthenticationBiometrics = myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
let hasAuthentication = myContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: nil)

if #available(iOS 11.0, *) {
if hasAuthentication {
if hasAuthenticationBiometrics {
switch myContext.biometryType {
case .none: return .none
case .faceID: return error?.code == -6 ? .passcode : .faceID // If user disabled face id in settings use passcode
case .touchID: return .touchID
}
} else {
return .passcode
}
} else {
return .none
}
}

关于ios - 如何知道是否启用了面容 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53778941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com