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 :(
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 :(
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."
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
}
}
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.
.biometryType
on the instance of laContext
with .canEvaluatePolicy(parameters)
. I did the mistake of using a new instance LAContext() every time. –
Elijah 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
}
© 2022 - 2024 — McMap. All rights reserved.