Skip to content

Instantly share code, notes, and snippets.

@bouchtaoui-dev
Created April 21, 2016 13:15
Show Gist options
  • Select an option

  • Save bouchtaoui-dev/d70a2b3bd5c75f6374c5d863fa9efffc to your computer and use it in GitHub Desktop.

Select an option

Save bouchtaoui-dev/d70a2b3bd5c75f6374c5d863fa9efffc to your computer and use it in GitHub Desktop.
#import <LocalAuthentication/LocalAuthentication.h>
/* A very simple way to scan your fingerprint... */
- (IBAction)didPressScan:(UIButton *)sender {
NSLog(@"Hallo...!");
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Used for quick and secure access to the Remob app :P";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
// User authenticated successfully, take appropriate action
NSLog(@"Yes baby! Fingerprint scanned!");
} else {
// User did not authenticate successfully, look at error and take appropriate action
NSLog(@"Damn you! I failed to defeat the dragon claw!");
}
}];
} else {
// Could not evaluate policy; look at authError and present an appropriate message to user
NSLog(@"Say what! No authentication?!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment