LAContext evaluationPolicy does not always request a user

In my iOS 7 iPad app, LAContext: calculatePolicy sometimes returns SUCCESS without prompting the user to touch the ID button. And Apple docs say, "Policy evaluation MAY include a user request ...".

My authentication policy is set to LAPolicyDeviceOwnerAuthenticationWithBiometrics, the only choice I see. Why not make the user touch the ID button every time I call a Policy rating? Is there a way I can require this behavior?

+4
source share
5 answers

I had a similar problem. Perhaps you are declaring a global variable something like

let authenticationContext = LAContext()

and then use the authenticationContext method in your class methods and functions.

I started declaring a constant in every function that I use as

func someAuthFunc() {
let authenticationContext = LAContext()
...

and my problem was resolved. I was asked every time I asked for an ForContext score ...

Hope this helps.

Greetings

+4
source

I have the same problem after updating iOS13. Not a very good workaround, but calling twice in valuPolicy method solved this problem for me

        context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { _, _ in
            context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { isSuccess, _ in
                DispatchQueue.main.async {
                    if isSuccess {
                        success()
                    } else {
                        fail(authError?.localizedDescription ?? "User did not authenticate successfully")
                    }
                }
            }
        }
0
source

iOS 13, 13.1, 13.2. - iOS 13.2, , .

: iOS 13 Touch ID Delay/Bug

0
source

It looks like it was fixed in 13.1.3

0
source

For those who have the same problem

It just happens with iOS 13 and above. The solution tries to call the function evaluatetwice like this:

let systemVersion = UIDevice.current.systemVersion
// Trick here: Try to do an pre-evaluate
if systemVersion.compare("13.0", options: .numeric) != .orderedAscending {
    context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (_, _) in
         //Ignore callback here
     })
}

context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (success, error) in
    // Handle callback here
})

Tested and works well for all versions of iOS 13.xx

0
source

Source: https://habr.com/ru/post/1626588/


All Articles