Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let context : LAContext = LAContext()
- var error: NSError?
- if context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthentication, error: &error) {
- context.evaluatePolicy(LAPolicy.deviceOwnerAuthentication,
- localizedReason: messageString,
- reply: { (success: Bool, evalPolicyError: Error?) -> Void in
- if success {
- //... perform login
- }
- }
- else {
- switch evalPolicyError!._code {
- case LAError.systemCancel.rawValue:
- print("Authentication was cancelled by the system")
- case LAError.userCancel.rawValue:
- print("Authentication was cancelled by the user")
- case LAError.userFallback.rawValue:
- print("User selected to enter custom password")
- default:
- print("Authentication failed")
- OperationQueue.main.addOperation({ () -> Void in
- print("Error input")
- })
- }
- }
- })
- }
- else {
- // If the security policy cannot be evaluated then show a short message depending on the error.
- switch error!.code{
- case LAError.touchIDNotEnrolled.rawValue:
- print("TouchID is not enrolled")
- case LAError.passcodeNotSet.rawValue:
- print("A passcode has not been set")
- default:
- // The LAError.TouchIDNotAvailable case.
- print("TouchID not available")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement