Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Last active August 29, 2015 14:06
Show Gist options
  • Save adamjleonard/cea89631c891d55e1e43 to your computer and use it in GitHub Desktop.
Save adamjleonard/cea89631c891d55e1e43 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 {
dispatch_async(dispatch_get_main_queue(), {
self.messageLabel.text = "Woohoo"
})
} else {
dispatch_async(dispatch_get_main_queue(), {
self.messageLabel.text = "Unable to Authenticate"
})
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment