TouchID を少しいじってみましたが、次の質問があります。
TouchID ログインに成功した後、新しい ViewController を提示するにはどうすればよいですか?
viewController.m のコードは次のとおりです。
#import "ViewController.h"
@import LocalAuthentication;
#import "SVProgressHUD.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
LAContext *context = [[LAContext alloc] init];
NSError *error;
// check if the policy can be evaluated
if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error])
{
NSLog(@"error:%@", error);
NSString *msg = [NSString stringWithFormat:@"Can't evaluate policy! %@", error.localizedDescription];
[SVProgressHUD showErrorWithStatus:msg];
return;
}
// evaluate
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Please login through TouchID"
reply:
^(BOOL success, NSError *authenticationError) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
[SVProgressHUD showSuccessWithStatus:@"Everything Worked!"];
//Code for new viewController should come here!
}
else {
NSLog(@"error:%@", authenticationError);
[SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"FAILED! %@", authenticationError.localizedDescription]];
}
});
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
viewController.h は標準です。何も変わっていません。サポートをありがとう:)