If user doesn't opts to use Face ID when presented with permission dialog, I'm getting biometryNotAvailable
error on calling canEvaluatePolicy(_:error:)
.
As per apple's docs, we should get it when device doesn't supports biometry. Im testing it on iPhone 12 Pro, Xcode 14, iOS 16 using deviceOwnerAuthenticationWithBiometrics
policy. Below is the code Im using:
var canEvaluatePolicy: Bool {
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
print("\(error?.localizedDescription)") // Prints "Biometry is not available."
return false
}
return true
}
Shouldn't I get biometryNotEnrolled
in this case? Any help is greatly appreciated.
In any project that uses biometrics, you should include the NSFaceIDUsageDescription key in your app’s Info.plist file.
If you accidentally have removed the permission on your iPhone 12 Pro, try Settings > Face ID & Passcode > Use Face ID For > Other Apps.
On the simulator, this option doesn't exist and your only option is Settings > General > Reset > Reset Location & Privacy
Make sure that FaceID is enabled on your iPhone.