LABiometryType in iOS11 always return None
Asked Answered
S

4

23

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 :(

Shoreward answered 3/10, 2017 at 9:51 Comment(3)
yeas both in iPhone 7 Plus running iOS 11 and iPad Pro 12.9 inch but with console log as "[LAClient] initWithExistingContext -> (null), Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.CoreAuthentication.daemon was invalidated from this process." UserInfo={NSDebugDescription=The connection to service named com.apple.CoreAuthentication.daemon was invalidated from this process.}"Shoreward
Possible duplicate of TouchID crash on some iPhone 5S devicesSubmerge
canEvaluatePolicy return True in iOS11 correctly as expected and evaluatePolicy is working good prompting touchId from user. I'm receiving the warning not the exception NSCocoaErrorDomainShoreward
S
37

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."

Subjacent answered 23/10, 2017 at 23:5 Comment(0)
P
4

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
            }
}
Parley answered 5/10, 2017 at 7:15 Comment(1)
It's not fair. Hope Apple to release the XCode9.1 before iPhone X launch.Shoreward
E
4

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.

Evelyne answered 27/11, 2017 at 21:20 Comment(1)
Yeah, the important thing is that you need to set .biometryType on the instance of laContext with .canEvaluatePolicy(parameters). I did the mistake of using a new instance LAContext() every time.Elijah
S
0

In Xamarin.iOS, you need evaluate the Policy Before:

   NSError error;
   bool success = context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out error);
   if (context.BiometryType == LABiometryType.TouchId)
   {
       //Do Something
   }
Selection answered 25/7, 2019 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.