IOS Touch ID Usage
After the iPhone 5 S is released, iOS devices basically have integrated Touch IDs, which is also a great extension for their apps. The usage of Touch IDS is roughly as follows,
Swift:
Introduce LocalAuthentication. framework
Import LocalAuthenticationvar myContext = LAContext () var error: NSError? Var localizedReasonString = "authentication prompt" if myContext. canEvaluatePolicy (LAPolicy. deviceOwnerAuthenticationWithBiometrics, error: & error) {// The third parameter is the closure myContext. evaluatePolicy (LAPolicy. deviceOwnerAuthenticationWithBiometrics, localizedReason: localizedReasonString, reply: {(success: Bool, error: NSError !) In if success {// authentication successful} else {// authentication failed, cause of error }})} else {// cannot authenticate, error message in error}
Objective-C writing
LAContext * myContext = [[LAContext alloc] init]; NSError * authError = nil; NSString * myLocalizedReasonString = "authentication prompt information"; if ([myContext canEvaluatePolicy: callback error: & authError]) {[myContext evaluatePolicy: Using localizedReason: myLocalizedReasonString reply: ^ (BOOL success, NSError * error) {if (success) {// authentication successful} else {// authentication failed, error contains error information}]} else {// cannot be authenticated, and authError contains error information}