0

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.

iAmd
  • 812
  • 1
  • 12
  • 22
  • 2
    No, biometry not enrolled means exactly what it says. Biometrics are available to your app but the user has not set them up. In the case where permission is denied then biometrics are just not available to your app and even though your app might "know" that the hardware exists your app is not permitted to know anything about the state of biometrics on the device and the appropriate response is to proceed as if the device does not have biometrics capability – Paulw11 Nov 09 '22 at 19:00

1 Answers1

1

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.

Luca Petra
  • 146
  • 6
  • Thanks @Luca-Petra. plist addition is already there. I just wasn't able to understand this error correctly. Paul's answer above really helps to understand it. – iAmd Nov 10 '22 at 06:48