Created
July 11, 2015 12:36
-
-
Save kurtisdunn/4bfff77259c1282e95f0 to your computer and use it in GitHub Desktop.
Touch ID Swift
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
let myContext = LAContext() | |
var authError: NSError? | |
// Set the reason string that will appear on the authentication alert. | |
var myReasonString = "String explaining why app needs authentication" | |
if myContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) { | |
[myContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: myReasonString, reply: { (success: Bool, evalPolicyError: NSError?) -> Void in | |
if success { | |
// User authenticated successfully | |
} else { | |
// Authenticate failed | |
} | |
})] | |
} else{ | |
// Could not evaluate policy; check authError | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment