Last active
January 16, 2018 09:59
-
-
Save DejanEnspyra/85a6d66edf1c434f05b01f1066e560a0 to your computer and use it in GitHub Desktop.
Face ID and Touch ID Authentication using 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
func authenticate(){ | |
let context = LAContext() | |
let reason = "We need this to protect your payments." // add your own message explaining why you need this authentication method | |
var authError: NSError? | |
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) { | |
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, error in | |
if success { | |
// User authenticated successfully | |
} else { | |
// User did not authenticate successfully | |
} | |
} | |
} else { | |
// Handle Error | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment