/faceid_evaluate.swift Secret
Created
October 3, 2018 08:53
Star
You must be signed in to star a gist
This file contains 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
self.authenticationContext = LAContext() | |
var errorPolicy: NSError? | |
if let authenticationContext = self.authenticationContext, | |
authenticationContext.canEvaluatePolicy(.deviceOwnerAuthentication, error: &errorPolicy) | |
{ | |
authenticationContext.localizedCancelTitle = NSLocalizedString("CONTEXT_CANCEL_TITLE", comment: "") | |
authenticationContext.localizedFallbackTitle = NSLocalizedString("CONTEXT_FALLBACK_TITLE", comment: "") | |
let authenticationReason = NSLocalizedString("CONTEXT_REASON", comment: "") | |
authenticationContext.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: authenticationReason ) { (success: Bool, error: Error?) -> Void in | |
if success | |
{ | |
print(NSLocalizedString("AUTHENTICATION_SUCCESS_MESSAGE", comment: "")) | |
DispatchQueue.main.async | |
{ | |
self.presentImage() | |
} | |
} | |
else | |
{ | |
if let error = error | |
{ | |
print(error.localizedDescription) | |
if let contextError = LAError.Code(rawValue: error._code) | |
{ | |
print(contextError.localizedDescription) | |
} | |
} | |
else | |
{ | |
print(NSLocalizedString("AUTHENTICATION_ERROR_MESSAGE", comment: "")) | |
} | |
} | |
} | |
} | |
else | |
{ | |
let message = errorPolicy?.localizedDescription ?? NSLocalizedString("AUTHENTICATION_POLICY_ERROR_MESSAGE", comment: "") | |
print(message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment