Touch IDの実装を考えてみました。といっても、Touch ID自体は2つ関数を呼ぶだけですので、簡単ですね。
まずは、Touch IDが使えるかの判定
#import <LocalAuthentication/LocalAuthentication.h>
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
return YES;
}
return NO;
使える場合は、Touch IDの呼び出し
LAContext *myContext = [[LAContext alloc] init];
NSString *myLocalizedReasonString = @"String explaining why app needs authentication";
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
// User authenticated successfully, take appropriate action
} else {
// User did not authenticate successfully, look at error and take appropriate action
}
}];
これだけでTouch IDが使えるなら、使わない訳にはいけないですね。
しかし、Touch IDに制御が移った時に、applicationDidBecomeActiveに移行して、認証完了後、applicationWillResignActiveに移行するので、起動処理にパスワード画面表示を行っている場合、表示順に気をつけないといけないです。。。

コメント