I'm trying to get if Face ID or Touch ID succeeded in the function below
func authenticate() -> Bool{
let context = LAContext()
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
return false
}
var returnValue = false
let reason = "Face ID authentication"
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason)
{
isAuthorized, error in
guard isAuthorized == true else {
return print(error)
}
returnValue = true
print("success")
}
return returnValue
}
but even when it succeeds with this code it skips the returnValue = true is passed later which results a false return.
why does this happen? and how can I fix this code to make it work like it is suppose to?
the code above is from this link just in case this person was watching, thank you.