How to access FaceID for the new iPhone X?

iPhone X comes out with FaceID introduced to unlock the phone and make Apple Pay.

Can we access the API?

I know that the last time we need to wait for the TouchID developer to be released.

Is there any date possible?

+4
source share
5 answers

In fact, it is already available in Xcode 9 in the same place as the TouchID feature. Look at LocalAuthentication -> LAContextLABiometryType -> for example.

, LAContext, API "" (, , Xcode 9 iOS 11 ).

+7

, , :


by @Paulw11 , API Touch ID - LAContext canEvaluatePolicy, , evaluatePolicy, - Face ID. , API Touch ID, "" ... , Apple , API iOS 8.

Talk Talk. , Apple, iPhone X, - , .., API, " " Face ID. API , , , , , , .


, @MichaelDautermanns , API Touch ID Face ID: LAContext biometryType , .

API Touch ID, Face ID, ? , . - , - , - , , Touch ID . , API, " Touch ID" " Face ID" .

+6

Xcode 9.0.1 9.1 beta (9B37) .

API-

Xcode 9.0 GM.

, iOS 11.0.0 ( iOS 11), biometryType. :

if #available(iOS 11.0.1, *) {...}

, Apple LABiometryType enum Xcode 9.2.

+4

Swift 4

enum BioType {
case kFace
case kTouch
case kNone
}

func checkForBiometry() -> BioType {
    let context = LAContext()

               if #available(iOS 11.0, *),context.responds(to: #selector(getter: LAContext.biometryType))  {
            if context.biometryType == .typeFaceID {

                return .kFace
        }
        return .kTouch
    }
    return .kNone
 }
}

Edit:

responds(to: #selector), , -[LAContext biometryType]: unrecognized selector iOS 11.0.0.

+3

, Xcode 9.

Xcode 9.1 beta, :

let authenticationContext = LAContext()
var error: NSError? = nil

if #available(iOS 11.0, *) {
    if authenticationContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error) {
        let bioType = authenticationContext.biometryType
        if bioType == .typeFaceID {
            touchIDButton.setImage(UIImage(named:"FaceIDLogo"), for: UIControlState.normal)
            touchIDButton.setImage(UIImage(named:"FaceIDLogo-Highlight"), for: UIControlState.highlighted)
        }
    }
}

, LAContext.canEvaluatePolicy.

+2

Source: https://habr.com/ru/post/1685712/


All Articles