實現iOS的指紋識別需要先
#import <LocalAuthentication/LocalAuthentication.h>
LAContext *la =[[LAContext alloc] init];
BOOL issupport = [la canEvaluatePolicy:kLAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL];
la.localizedFallbackTitle = @"enter password"; // 驗證失敗後備選提示
if (issupport) {
[la evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"give me five" reply:^(BOOL success, NSError * _Nullable error) {
if (success) {
NSLog(@"驗證指紋成功");
}else
{
NSLog(@"驗證指紋失敗error= %@ ",[error localizedDescription]);
if (error.code == kLAErrorUserFallback) {
NSLog(@"需要輸入密碼"); // 可以自己設置密碼比對
}
}
}];
}