2017-02-11 15 views

답변

-1

jailbroken 장치에서 개인 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 

먼저 당신이 지문이 있는지 확인하십시오 :

은 여기에서 목표 - C에서 정말 기본적인 구현 MyViewController, UIViewController의 서브 클래스 (당신은 결국 거기에서 논리를 이동 할 수 있습니다)를 척입니다 기기에서 설정하십시오 (설정> 터치 ID & 비밀번호> 지문 섹션).