-2

I would like to know how to start monitor for finger prints like this tutorial explains but it is out of date so it doesnt work.

Thanks in advance.

1 Answers1

-1

If you want to play around with the private BiometricKit framework on a jailbroken device I can't really help...
If you're only interested in leveraging the TouchID functionality though, you only need to use the public LocalAuthentication framework.

Here's a really basic implementation in Objective-C in a pretend MyViewController, subclass of UIViewController (You might eventually want to move the logic out of there):

#import "MyViewController.h"
@import LocalAuthentication;

@interface MyViewController ()
@property (nonatomic, strong) LAContext *localAuthContext;
@end


@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self authenticateWithTouchID]; // Call this whenever TouchID authentication is required.
}

#pragma mark - TouchID Authentication

- (void)authenticateWithTouchID {
    NSError *evaluationError;
    if (![self.localAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&evaluationError]) {
        // TODO: Handle error case. (device with no TouchID capability)
        NSLog(@"%@", evaluationError.localizedDescription);
    } else {
        [self.localAuthContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                              localizedReason:@"Authenticate using Touch ID"
                                        reply:^(BOOL success, NSError *error) {

                                            if (!success) {
                                                // TODO: Handle error case. (failed TouchID authentication)
                                                NSLog(@"%@", error.localizedDescription);
                                            } else {
                                                // TODO: Handle success case.
                                                NSLog(@"TouchID authentication successful.");
                                            }
                                        }];
    }
}

#pragma mark - Lazy Instantiation

- (LAContext *)localAuthContext
{
    if (!_localAuthContext) {
        _localAuthContext = [[LAContext alloc] init];
        _localAuthContext.localizedFallbackTitle = @""; // Hides the "Enter Password" button. Comment out to allow the user to enter his device passcode as a fallback option.
    }
    return _localAuthContext;
}

@end

First make sure that you have a fingerprint set up on your device (Settings > Touch ID & Passcode > Fingerprints section).

Olivier
  • 858
  • 8
  • 17