iOS11中的LABiometryType始终返回None

guh*_*an0 21 biometrics lacontext ios11 localauthentication face-id

在此输入图像描述

无论在Device的密码和touchId设置中配置了什么设置,LAContext始终都不返回任何设置.它只是给我一个警告而不是例外.

它只能在iOS11.1测试版的XCode 9.1 Beta中工作:

Erm*_*ish 26

我刚刚发现了问题!你必须调用canEvaluatePolicybiometryType要正确设置.

例:

func isFaceIdSupported() -> Bool {
    if #available(iOS 11.0, *){
        if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
            return context.biometryType == LABiometryType.typeFaceID
        }
    }

    return false
}
Run Code Online (Sandbox Code Playgroud)

根据Apple docs for biometryType:

"此属性仅在canEvaluatePolicy(_:error :)成功生成生物识别策略时设置.默认值为none."