-
-
Save markedwardmurray/d1037b018e49c34142c2d533f1276162 to your computer and use it in GitHub Desktop.
FaceID_BiometryManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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