[英]What happens if I use LAPolicyDeviceOwnerAuthentication on iOS 8?
[英]iOS LAPolicyDeviceOwnerAuthentication “Cancel” Button
我目前在我的應用程序中使用LAPolicyDeviceOwnerAuthentication來進行TouchID /密碼驗證。 但是,如果用戶單擊“取消”,則我的應用程序僅關閉touchID /密碼驗證,並且不執行任何操作。 有沒有辦法讓我再次重新啟動touchID驗證過程?
這是我目前正在嘗試做的事情:
-(void)callAuthenticate {
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Please Enter Touch ID";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"showList" sender:nil];
});
} else if (error){
NSString *errorMessage;
BOOL showError = NO;
switch (error.code) {
case LAErrorAuthenticationFailed:
errorMessage = @"Sorry couldn't autheticate";
showError = YES;
break;
case LAErrorPasscodeNotSet:
errorMessage = @"No Passcode has been set";
showError = YES;
break;
case LAErrorTouchIDNotEnrolled:
errorMessage = @"Touch ID has no enrolled fingers";
showError = YES;
break;
default:
showError = NO;
break;
}
if (showError) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:errorMessage
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
}
}];
} else {
[self performSegueWithIdentifier:@"showList" sender:nil];
}
}
謝謝您的幫助! :-)
當錯誤代碼為LAErrorUserCanceled
時,您需要處理這種情況。 當前,這是由default:
case處理的,它什么也不做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.