Checking is Biometry is Enrolled

Hi


What is the best way to determine if an iPhone or iPad has a biometry sensor? The user may or may not have registered their face or fingerprint, regardless I would like to know what biometry sensor is on the device. My app targets iOS 11, so it has to be either Touch or Face.


Many thanks


Craig

Answered by craigaps in 679617022

You need to evaluate policy first to determine if biometry is available.

var biometryType: LABiometryType {
    var error: NSError?
    let context = LAContext()

    guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {    
        return .none
    }

    return context.biometryType
}


// Test the biometry type
switch self.biometryType {
    case .faceID:
        print("Face ID")
    case .touchID:
        print("Touch ID")
    case .none:
        print("None")
    @unknown default:
        print("Unknown")
}

Accepted Answer

You need to evaluate policy first to determine if biometry is available.

var biometryType: LABiometryType {
    var error: NSError?
    let context = LAContext()

    guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {    
        return .none
    }

    return context.biometryType
}


// Test the biometry type
switch self.biometryType {
    case .faceID:
        print("Face ID")
    case .touchID:
        print("Touch ID")
    case .none:
        print("None")
    @unknown default:
        print("Unknown")
}

Checking is Biometry is Enrolled
 
 
Q