首先引入類名:
#import <LocalAuthentication/LocalAuthentication.h>
其次:
LAContext?* authenticationContext = [[LAContextalloc]?init];
NSError* error = [[NSErroralloc]init];
? ??BOOL?isTouchIdAvailable? = [authenticationContext?canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics?error:&error];
if(isTouchIdAvailable ) {
NSLog(@"認(rèn)證策略成功");
//可以進(jìn)行指紋識(shí)別認(rèn)證,在Home鍵錄入指紋比對(duì)
? ? ? ? [authenticationContext?evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricslocalizedReason:@"需要驗(yàn)證您的指紋來確認(rèn)您的身份信息"?reply:^(BOOL?success,?NSError?*error) {
if(success) {
? ? ? ? ? ? ? ??NSLog(@"恭喜,您通過了Touch ID指紋驗(yàn)證!");
}else{
? ? ? ? ? ? ? ??NSLog(@"抱歉,您未通過了Touch ID指紋驗(yàn)證!");
? ? ? ? ? ? }
? ? ? ? }];
}else{
? ? ? ??NSLog(@"認(rèn)證策略失敗,error ===? %@",error);
? ? }