Last active
July 28, 2017 17:58
-
-
Save jstart/58b941b91f182ba8d6a0 to your computer and use it in GitHub Desktop.
Touch ID Example
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
LAContext *myContext = [[LAContext alloc] init]; | |
NSError *authError = nil; | |
NSString *myLocalizedReasonString = @"Authenticate using your finger"; | |
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { | |
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics | |
localizedReason:myLocalizedReasonString | |
reply:^(BOOL success, NSError *error) { | |
if (success) { | |
NSLog(@"User is authenticated successfully"); | |
} else { | |
switch (error.code) { | |
case LAErrorAuthenticationFailed: | |
NSLog(@"Authentication Failed"); | |
break; | |
case LAErrorUserCancel: | |
NSLog(@"User pressed Cancel button"); | |
break; | |
case LAErrorUserFallback: | |
NSLog(@"User pressed \"Enter Password\""); | |
break; | |
default: | |
NSLog(@"Touch ID is not configured"); | |
break; | |
} | |
NSLog(@"Authentication Fails"); | |
} | |
}]; | |
} else { | |
NSLog(@"Can not evaluate Touch ID"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment