Skip to content

Instantly share code, notes, and snippets.

@markedwardmurray
Created November 3, 2017 18:16
Show Gist options
  • Save markedwardmurray/d1037b018e49c34142c2d533f1276162 to your computer and use it in GitHub Desktop.
Save markedwardmurray/d1037b018e49c34142c2d533f1276162 to your computer and use it in GitHub Desktop.
FaceID_BiometryManager.swift
import LocalAuthentication
enum BiometryType {
case none, typeTouchID, typeFaceID
}
class BiometryManager {
var biometryType: BiometryType {
let context = LAContext()
var error = NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else {
print(error?.localizedDescription ?? "")
return .none
}
if #available(iOS 11, *) {
switch context.biometryType {
case .none:
return .none
case .typeTouchID:
return .typeTouchID
case .typeFaceID:
return .typeFaceID
}
} else {
return .typeTouchID
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment