iOS 개발 중 지문 인식 에 대한 간단 한 소개

4011 단어 ios지문 인식
ios 개발 에서 지문 인식 에 대한 간단 한 소 개 는 아이 폰 시리즈 에서 5S 이후 지문 인식 기능 이 생 겨 ios 8 때 열 린 지문 검증 인터페이스 이다.
그래서 우 리 는 지문 인식 애플 리 케 이 션 을 할 때 기종 과 시스템 버 전 을 판단 해 야 한다.
코드 는 다음 과 같 습 니 다.다음 에 특히 주의해 야 할 것 은 바로 LAPolicy DeviceOwner Authentication 과 LAPolicy DeviceOwner Authentication With Biometrics 의 차이 점 입 니 다.검 측 시스템 의 버 전 은[UIDevice currentDevice].systemVersion.floatValue 를 통 해 장치 가 Touch ID 를 사용 할 수 있 는 지 여 부 를 판단 하 는 것 은 canEvaluate Policy:error:이 방법 으로 판단 합 니 다.그리고 주의해 야 할 것 은 지문 인식 성공 여 부 를 검증 하 는 작업 은 기본적으로 하위 스 레 드 에서 진행 되 기 때문에 UI 작업 을 하려 면 메 인 스 레 드 로 돌아 가 실행 해 야 합 니 다.4dispatch_async(dispatch_queue_t _Nonnull queue, ^{ }) 이 함 수 를 이용 하여 실현 할 수 있 습 니 다.그 안에 홈 팀 열 에 들 어가 면 됩 니 다.그리고 저 희 는 eror 의 code 에 따라 사용자 가 구체 적 으로 어떤 원인 으로 인해 잘못 되 었 는 지 판단 한 다음 에 해당 하 는 출력 을 할 수 있 습 니 다.

//1、             8.0                   
  if([UIDevice currentDevice].systemVersion.floatValue>=8.0)
  {
  //               ,  5S          
   //  LA      
    LAContext * context = [[LAContext alloc]init];
    //            
    //Evaluate        
    //Policy      
    //            touchID
    if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil])
    {
   //LAPolicyDeviceOwnerAuthentication              ,       ,         。                   
                            touch ID     , LAPolicyDeviceOwnerAuthenticationWithBiometrics        
        ,        ,         ,                  ,              touch id     
     //            
      [context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@"         " reply:^
    (BOOL success, NSError * _Nullable error) {
        //           ,     UI  ,              
        //      
        if(success)
        {
          NSLog(@"%@",[NSThread currentThread]);
          NSLog(@"    ");
        }
        else
        {
          NSLog(@"    ");
        }
        NSLog(@"%@",[NSThread currentThread]);
        NSLog(@"%@",error);
        if(error)
        {
         if(error.code==-2)
         {
         dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"      " message:@""
          preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"  " style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
UIAlertAction * action1 = [UIAlertAction actionWithTitle:@"  " style:UIAlertActionStyleCancel 
           handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"hhhhhh");
}];
[vc addAction:action];
[vc addAction:action1];
[self presentViewController:vc animated:YES completion:nil];
});
         }
         else if(error.code==-1)
         {
         dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"      3 " message:
            @"       " preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"  " style:UIAlertActionStyleDefault 
            handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
[vc addAction:action];
[self presentViewController:vc animated:YES completion:nil];
});
         }
        }
      }];
    }
  }
  else
  {
    NSLog(@"   ,      ");
  }
총결산
위 에서 말 한 것 은 편집장 님 께 서 소개 해 주신 iOS 개발 에서 지문 인식 에 대한 간단 한 소개 입 니 다.여러분 께 도움 이 되 셨 으 면 좋 겠 습 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.편집장 님 께 서 바로 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!

좋은 웹페이지 즐겨찾기