Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Created September 28, 2014 00:09
Show Gist options
  • Save adamjleonard/93b4bab7aba7a293b485 to your computer and use it in GitHub Desktop.
Save adamjleonard/93b4bab7aba7a293b485 to your computer and use it in GitHub Desktop.
func requestFingerprintAuthentication() {
let context = LAContext()
var authError: NSError?
let authenticationReason: String = "To display a message to the user"
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: authenticationReason, reply: {
(success: Bool, error: NSError?) -> Void in
if success {
self.updateMessageLabel("Woohoo")
} else {
self.updateMessageLabel("Unable to Authenticate")
}
})
}
}
func updateMessageLabel(message: String) {
dispatch_async(dispatch_get_main_queue(), {
self.messageLabel.text = message
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment