gpt4 book ai didi

iOS - 面容 ID 生物识别集成

转载 作者:搜寻专家 更新时间:2023-10-30 22:24:55 27 4
gpt4 key购买 nike

我已经为我的应用程序集成/实现了面容 ID(本地身份验证)身份验证,一切正常,除了面容 ID 提示警报窗口界面。

It shows, a rounded square with a light gray background and the title "Face ID".

标题正上方的空白区域需要设置什么?是面部识别图标的空间吗?如果是,那我该如何设置呢?我已经尝试了 LAContext 和 LAPolicy 中的所有内容。

看看这个快照:

enter image description here

这是我的代码:

    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
}


laContext.evaluatePolicy(biometricsPolicy, localizedReason: localizedReason, reply: { (isSuccess, error) in

DispatchQueue.main.async(execute: {

if let laError = error {
print("laError - \(laError)")
} else {
if isSuccess {
print("sucess")
} else {
print("failure")
}
}

})
})
}

最佳答案

这只发生在模拟器中,在实际设备中 Canvas 被面部图标动画占据。

localizedReason 仅适用于 Touch ID,因为它们共享相同的 API。

更新 1:添加屏幕录像:

他们都运行相同的代码:

func beginFaceID() {

guard #available(iOS 8.0, *) else {
return print("Not supported")
}

let context = LAContext()
var error: NSError?

guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
return print(error)
}

let reason = "Face ID authentication"
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { isAuthorized, error in
guard isAuthorized == true else {
return print(error)
}

print("success")
}

}

这是包含所有错误代码的 TouchID 和 FaceID 的工作代码(Swift 4)

https://stackoverflow.com/a/52093551/10150796

关于iOS - 面容 ID 生物识别集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47183108/

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