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) {
let context = LAContext()
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
completion(true)
return
}
context.localizedCancelTitle = "Cancel"
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in
DispatchQueue.main.async {