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.

Replies

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"

  • Well, it takes some time to modify my code.

    Before do that, please let me ask you the following question;

    "Is that the standard usage of Biometrics authentication to use a button action after back from background?"

  • I added a button and check if it works. The result is, I still see the problem.

Add a Comment