20 lines
620 B
Swift
20 lines
620 B
Swift
import Foundation
|
|
import LocalAuthentication
|
|
|
|
enum AppLockService {
|
|
static func canUseBiometrics() -> Bool {
|
|
let context = LAContext()
|
|
var error: NSError?
|
|
return context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
|
|
}
|
|
|
|
static func authenticate(reason: String, completion: @escaping (Bool) -> Void) {
|
|
let context = LAContext()
|
|
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, _ in
|
|
DispatchQueue.main.async {
|
|
completion(success)
|
|
}
|
|
}
|
|
}
|
|
}
|