//導入本地授權
#import <LocalAuthentication/LocalAuthentication.h>
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//1.創(chuàng)建上下文
LAContext *context = [[LAContext alloc] init];
//2.判斷指紋識別是否可用
/*
LAPolicyDeviceOwnerAuthenticationWithBiometrics kLAPolicyDeviceOwnerAuthenticationWithBiometrics
*/
if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]){
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"按住Home鍵驗證" reply:^(BOOL success, NSError * _Nullable error) {
if(error){
//-1表示連續(xù)錯誤3次
//-8再次錯誤
//-3點擊輸入密碼
NSLog(@"%zd",error.code);
}
if(success){
NSLog(@"驗證成功");
}
}];
}
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者