相关疑难解决方法(0)

人脸ID评估流程无法正常运行

我正在尝试获取以下功能中的Face ID或Touch ID是否成功

func authenticate() -> Bool{

    let context = LAContext()
    var error: NSError?

    guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
        return false
    }
    var returnValue = false
    let reason = "Face ID authentication"
    context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) 
    {
        isAuthorized, error in
        guard isAuthorized == true else {
            return print(error)
        }
        returnValue = true
        print("success")
    }
    return returnValue        
}
Run Code Online (Sandbox Code Playgroud)

但是即使此代码成功执行,它也会跳过,returnValue = true稍后再传递,导致返回错误。为什么会这样?以及如何解决此代码以使其像预期的那样工作?

上面的代码来自此链接 ,以防万一此人正在观看,谢谢。

authentication ios touch-id swift face-id

6
推荐指数
1
解决办法
2074
查看次数

标签 统计

authentication ×1

face-id ×1

ios ×1

swift ×1

touch-id ×1