LAPolicy.deviceOwnerAuthenticationWithBiometrics always returns "success" when back from background.

I would like to use Biometrics authentication when my iOS app comes back from background. I added this process but it always returns "success".

Is this iOS Biometrics authentication spec?

If not, please let me know how to do.

Additional information,

  1. Biometrics authentication works when first login to my iOS app.
  2. Finish app and go to background
  3. Activate app to get back from background. Biometrics authentication works but always returns "success"

It works fine at 1. operation because it is the very first Biometrics authentication. On the other hand, it always returns "success" from 2nd trial.

If I terminate the app and re-activate it, Biometrics authentication works fine. Therefore, I wonder if Biometrics authentication would not work correctly when get back from background.

Can you post some more details about your issue:

  • What specific API are you calling?

  • And in what context? That is, are you calling it from your -applicationWillEnterForeground: method? Or does it happen if, say, you wire up a button and tap that button when your app comes to the foreground.

  • How are you managing your LAContext instance?

  • Is this on a device with Touch ID? Or Face ID? Or both?

  • And on what version of iOS?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for your response.

Please let me tell you another additional information, which is, I use SwiftUI.

Please let me answer your questions as follow;

  • The following is the code I use;
  private var context = LAContext()

  public func checkBiometric() -> Future<Bool, Error> {
    Future { [context] promise in
      Task { [promise, context] in
        context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics,
                               localizedReason: "Some reason") { success, error in
            if success {
              promise(.success(success))
            } else {
              promise(.failure(error as! LAError))
            }
        }
      }
    }
  }
  • This is called right after lifecycle status becomes "active" from "background".
  • The test device is iPhone 13 pro with iOS 15.5, and Face ID.

If you need more information, please feel free to contact me.

Best regards,

This is called right after lifecycle status becomes "active" from "background".

OK. If you disable that and instead wire this code up to a button, do you still see the problem?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

LAPolicy.deviceOwnerAuthenticationWithBiometrics always returns "success" when back from background.
 
 
Q