Created
April 29, 2017 14:23
-
-
Save apple-avadhesh/fd953c110d221192e22373c510ec4766 to your computer and use it in GitHub Desktop.
Touch Id Authentication
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
import UIKit | |
import LocalAuthentication | |
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 { | |
print("Success") | |
} else { | |
print("Unable to Authenticate") | |
} | |
} as! (Bool, Error?) -> Void) | |
} | |
} | |
func updateMessageLabel(message: String) { | |
DispatchQueue.main.async { | |
print(message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment