Skip to content

Instantly share code, notes, and snippets.

@Maxim-Kolmogorov
Created November 2, 2020 04:25
Show Gist options
  • Save Maxim-Kolmogorov/7bf34b3e9f3c14ac68919603c6a4cc8c to your computer and use it in GitHub Desktop.
Save Maxim-Kolmogorov/7bf34b3e9f3c14ac68919603c6a4cc8c to your computer and use it in GitHub Desktop.
Face/Touch ID Authorization
import LocalAuthentication
private func indetifyYourself() {
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
let reason = "Идентифицируйте себя"
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in
if success {
DispatchQueue.main.async { [unowned self] in
print("Успешная авторизация")
}
}
}
} else {
print("Face/Touch ID не найден")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment