標籤:
1:添加LocalAuthentication.framework架構2:實現過程#import "ViewController.h"#import <LocalAuthentication/LAContext.h>@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; LAContext *myContext = [[LAContext alloc]init]; myContext.localizedFallbackTitle = @"忘記密碼"; NSError *error = nil; NSString *myLocalizedReasonString = @"請輸入指紋"; if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:myLocalizedReasonString reply:^(BOOL success, NSError *error) { if (success) { NSLog(@"success"); } else { // User did not authenticate successfully, look at error and take appropriate action NSLog(@"did not authenticate successfully"); } }]; } else { // Could not evaluate policy; look at authError and present an appropriate message to user NSLog(@"Could not evaluate policy"); } }
ios 指紋識別解鎖