LABiometryType in iOS11 always return None
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.
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
}
}