Ask for owner authentication only when applicable

This commit is contained in:
Ivan Grachyov 2021-06-13 15:39:31 +03:00
parent f02cb7fb8b
commit 381f0176fd

View File

@ -86,6 +86,13 @@ class Agent {
private func proceedAfterAuthentication(reason: String, completion: @escaping (Bool) -> Void) { private func proceedAfterAuthentication(reason: String, completion: @escaping (Bool) -> Void) {
let context = LAContext() let context = LAContext()
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
completion(true)
return
}
context.localizedCancelTitle = "Cancel" context.localizedCancelTitle = "Cancel"
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in
DispatchQueue.main.async { DispatchQueue.main.async {