Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LABiometryType in iOS11 always return None

enter image description here

No matter what settings is configured in Device's passcode and touchId settings , LAContext always returns none . It is just throwing me a warning not the exception.

Its only working in XCode 9.1 Beta in iOS11.1 beta as suggested :(

like image 690
guhan0 Avatar asked Oct 03 '17 09:10

guhan0


3 Answers

I just figured out the problem! You have to call canEvaluatePolicy for biometryType to be properly set.

Example:

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

    return false
}

As per the Apple docs for biometryType:

"This property is only set when canEvaluatePolicy(_:error:) succeeds for a biometric policy. The default value is none."

like image 113
ermish Avatar answered Nov 03 '22 17:11

ermish


If you use the code from @Ermish, isFaceIdSupported() will return false if there are no enrolled faces on the device. As per my latest tests shows on iOS SDK 11.1, just call the laContext.canEvaluatePolicy function and do not care about the result, then check the content of laContext.biometryType.

If there are no enrolled faces, the canEvaluatePolicy will fail, but the device supports Face ID.

like image 34
Lee-der Avatar answered Nov 03 '22 18:11

Lee-der


Got the same issue here, fixed it with the following code. But it only works with the Xcode 9.1 Beta (and iOS 11.1 beta in the simulator).

if (laContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: nil)) {

            if #available(iOS 11.0, *) {
                if (laContext.biometryType == LABiometryType.faceID) {
                    print("FaceId support")
                } else if (laContext.biometryType == LABiometryType.touchID) {
                    print("TouchId support")
                } else {
                    print("No Biometric support")
                }
            } else {
                // Fallback on earlier versions
            }
}
like image 42
NBoymanns Avatar answered Nov 03 '22 19:11

NBoymanns