iOS 10 beta - TouchID 登录不弹出密码键盘
iOS 10 beta - TouchID login does not pop up pin pad
在 iOS 9.x 中,在尝试生物识别登录 5 次(3 次,然后 2 次)后,iOS 会自动弹出一个默认的 PIN 码屏幕。 iOS 10 Beta 中不会发生这种情况。它只是使 "canEvaluatePolicy" 检查失败。有谁知道这只是 iOS 10 Beta 中的一个错误,还是我必须以某种方式添加代码以支持 PIN 码屏幕?
代码如下:
-(void)touchTester {
LAContext *myContext = [[[LAContext alloc] init] autorelease];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Sign on with TouchID\u00AE or enter password.";
myContext.localizedFallbackTitle = @"Enter Password";
self.touchIdActive = NO;
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
self.touchIdActive = YES;
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Launching loginUser");
[self loginUser:YES];
});
} else {
self.touchIdActive = NO;
NSString * errMsg = error.localizedDescription;
if (![errMsg isEqualToString:@"Canceled by user."]) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:errMsg
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
}
}];
} else {
// This is where we go after lockout in iOS 10
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:authError.localizedDescription
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
}
显示代码:
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
TouchType typeState = TouchTypeOther;
if (success) {
NSLog(@"解锁成功");
} else {
if(error.code == -8){
dispatch_async(dispatch_get_main_queue(), ^{
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
}];
}
});
}
}
}];
} else {
if(authError.code == -8){
dispatch_async(dispatch_get_main_queue(), ^{
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
}];
}
});
}
NSLog(@"%@",authError);
}
在 iOS 9.x 中,在尝试生物识别登录 5 次(3 次,然后 2 次)后,iOS 会自动弹出一个默认的 PIN 码屏幕。 iOS 10 Beta 中不会发生这种情况。它只是使 "canEvaluatePolicy" 检查失败。有谁知道这只是 iOS 10 Beta 中的一个错误,还是我必须以某种方式添加代码以支持 PIN 码屏幕?
代码如下:
-(void)touchTester {
LAContext *myContext = [[[LAContext alloc] init] autorelease];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Sign on with TouchID\u00AE or enter password.";
myContext.localizedFallbackTitle = @"Enter Password";
self.touchIdActive = NO;
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
self.touchIdActive = YES;
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Launching loginUser");
[self loginUser:YES];
});
} else {
self.touchIdActive = NO;
NSString * errMsg = error.localizedDescription;
if (![errMsg isEqualToString:@"Canceled by user."]) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:errMsg
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
}
}];
} else {
// This is where we go after lockout in iOS 10
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:authError.localizedDescription
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
}
显示代码:
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
TouchType typeState = TouchTypeOther;
if (success) {
NSLog(@"解锁成功");
} else {
if(error.code == -8){
dispatch_async(dispatch_get_main_queue(), ^{
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
}];
}
});
}
}
}];
} else {
if(authError.code == -8){
dispatch_async(dispatch_get_main_queue(), ^{
LAContext *myContext = [[LAContext alloc] init];
myContext.localizedFallbackTitle = [InternationalControl localStringByKey:@"gesture_forget"];
NSError *authError = nil;
NSString *myLocalizedReasonString = [InternationalControl localStringByKey:@"touchHome"];
BOOL isOK = [myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError];
if (isOK) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
NSLog(@" 查看是什么情况 %@",error);
}];
}
});
}
NSLog(@"%@",authError);
}