Created
September 28, 2014 00:09
-
-
Save adamjleonard/93b4bab7aba7a293b485 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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