2017-02-11 4 views

答えて

-1

あなたは、私が実際に助けることができないジェイルブレイクデバイス上にプライベートBiometricKitフレームワークで遊んしたい場合は...
あなたががTouchID機能を活用で唯一興味があるなら、あなたは唯一の公共を使用する必要がありますLocalAuthenticationフレームワーク。

#import "MyViewController.h" 
@import LocalAuthentication; 

@interface MyViewController() 
@property (nonatomic, strong) LAContext *localAuthContext; 
@end 


@implementation MyViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self authenticateWithTouchID]; // Call this whenever TouchID authentication is required. 
} 

#pragma mark - TouchID Authentication 

- (void)authenticateWithTouchID { 
    NSError *evaluationError; 
    if (![self.localAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&evaluationError]) { 
     // TODO: Handle error case. (device with no TouchID capability) 
     NSLog(@"%@", evaluationError.localizedDescription); 
    } else { 
     [self.localAuthContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics 
           localizedReason:@"Authenticate using Touch ID" 
             reply:^(BOOL success, NSError *error) { 

              if (!success) { 
               // TODO: Handle error case. (failed TouchID authentication) 
               NSLog(@"%@", error.localizedDescription); 
              } else { 
               // TODO: Handle success case. 
               NSLog(@"TouchID authentication successful."); 
              } 
             }]; 
    } 
} 

#pragma mark - Lazy Instantiation 

- (LAContext *)localAuthContext 
{ 
    if (!_localAuthContext) { 
     _localAuthContext = [[LAContext alloc] init]; 
     _localAuthContext.localizedFallbackTitle = @""; // Hides the "Enter Password" button. Comment out to allow the user to enter his device passcode as a fallback option. 
    } 
    return _localAuthContext; 
} 

@end 

まずあなたが指紋を持っていることを確認してください:ここで

UIViewControllerの、MyViewControllerをふり、サブクラス(あなたが最終的にそこから出ロジックを移動する場合があります)でのObjective-Cで本当に基本的な実装です(設定>タッチID &パスコード>指紋セクション)を設定します。

関連する問題