2017-09-13 5 views
5

시뮬레이터에서 최신 Xcode 9 GM (2019 년 9 월 13 일)을 실행했으며 Deployment Target 11.0을 설정했습니다. 그러나 오류 코드 -이 나타납니다.iOS 11 시뮬레이터에서 LAContext 및 FaceID를 허용하지 않음

일부 설정이 누락 되었습니까?

let myContext = LAContext() 
let myLocalizedReasonString = "You are pretty" 

var authError: NSError? 
if #available(iOS 8.0, macOS 10.12.1, *) { 
    if myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) { 
     myContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: myLocalizedReasonString) { success, evaluateError in 
      if success { 

       print("// User authenticated successfully, take appropriate action") 
      } else { 
       print(" // User did not authenticate successfully, look at error and take appropriate action") 
      } 
     } 
    } else { 
     print(" // Could not evaluate policy; look at authError and present an appropriate message to user") 
    } 
} else { 
    print(" // Fallback on earlier versions") 
} 
+0

사용이 라이브러리는 그 faceid을 지원 모두 touchid . https://github.com/tejas-ardeshna/TJBioAuthentication –

답변

8

프레임 워크 버그로 인해 Face ID가 Xcode 9 GM에서 작동하지 않습니다. Xcode 9.1에서는이 문제를 해결합니다.

iPhone 8 시뮬레이터에서 앱을 테스트하고 Touch ID로 올바르게 작동하는지 확인하거나 Xcode 9.1 베타를 실행하고 거기에서 Face ID 지원을 테스트 할 수 있습니다.

1

Xcode 9.1 베타는 오늘 원본 코드가 시뮬레이터에서 완벽하게 작동해야합니다!

1

LAContext의 Apple 설명서에 따르면 NSFaceIDUsageDescription 키에 이유를 추가해야합니다. String을 사용하면 기기에 FaceId 사용에 대한 승인 요청이 표시됩니다.

예이의 Info.plist에 추가 :

NSFaceIDUsageDescription 

는 문자열을 입력하고 얼굴 ID 카메라에 액세스하기위한 프롬프트 요청에, 당신이 표시하려는 텍스트를 추가로 설정합니다. 이 문제를 추가하여

"Your app" request your permission to use Face ID, for you to login to your account/unlock your notes/what ever reason in the end. 

, 당신은 아이폰 X 용 시뮬레이터에 갈 수 있습니다, 당신은 얼굴 ID를 입력하라는 메시지가 표시됩니다 눌러 적용하고 모든 것을 완벽하게 작동합니다. https://developer.apple.com/documentation/localauthentication/lacontext

:

것은 다음 방금 자세한 내용은 사용자의 취급

을 테스트하고 애플의 설명서를 확인하려면 Match/Non-Matching Touch/Face ID을 누를 필요가 Simulator -> Hardware -> Face ID/Touch ID -> Enrolled

로 이동하여 시뮬레이터를위한 생체 인식 지원을 등록하는 것을 잊지 마십시오

---- 편집 ----

이는 엑스 코드 9.0 및 9.1

모두 나를 위해 일한
2

얼굴 ID가 Xcode 9.1에서 작동 중입니다. 시뮬레이터에서 테스트하려면 다음 단계를 따르십시오.

대상의 info.plist 파일에 개인 정보 취급 방침을 추가하십시오.

enter image description here

가져 오기 LocalAuthentication 프로젝트에 프레임 워크와보기 컨트롤러에 다음 코드를 추가하고

import LocalAuthentication 

class ViewController: UIViewController { 


    override func viewDidLoad() { 
     super.viewDidLoad() 
     localAuthentication() 
    } 



    func localAuthentication() -> Void { 

     let laContext = LAContext() 
     var error: NSError? 
     let biometricsPolicy = LAPolicy.deviceOwnerAuthenticationWithBiometrics 

     if (laContext.canEvaluatePolicy(biometricsPolicy, error: &error)) { 

      if let laError = error { 
       print("laError - \(laError)") 
       return 
      } 

      var localizedReason = "Unlock device" 
      if #available(iOS 11.0, *) { 
       if (laContext.biometryType == LABiometryType.faceID) { 
        localizedReason = "Unlock using Face ID" 
        print("FaceId support") 
       } else if (laContext.biometryType == LABiometryType.touchID) { 
        localizedReason = "Unlock using Touch ID" 
        print("TouchId support") 
       } else { 
        print("No Biometric support") 
       } 
      } else { 
       // Fallback on earlier versions 
      } 


      laContext.evaluatePolicy(biometricsPolicy, localizedReason: localizedReason, reply: { (isSuccess, error) in 

       DispatchQueue.main.async(execute: { 

        if let laError = error { 
         print("laError - \(laError)") 
        } else { 
         if isSuccess { 
          print("sucess") 
         } else { 
          print("failure") 
         } 
        } 

       }) 
      }) 
     } 


    } 
} 


FaceID 인증 FaceID을 허용하는 처음 메시지를 표시합니다 FaceID으로 시도 앱 감지. enter image description here


지금 페이스 ID 등록을 활성화하고 얼굴 ID 시뮬레이션 테스트를 테스트하여 응용 프로그램을 실행합니다.

enter image description here

찾는 매칭면을 비 매칭 시뮬레이션 결과이다. 일치하는 얼굴

결과 : 비 매칭 얼굴

enter image description here


결과 :

enter image description here

+1

완벽하게 잘 작동합니다. –

관련 문제