Last active
January 31, 2020 17:20
-
-
Save sourleangchhean168/080294527a65f0faa131441949c90aff to your computer and use it in GitHub Desktop.
Revisions
-
sourleangchhean168 revised this gist
Jan 31, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ //Noted: This code is written in Swift 5.1 //By: Sour Leangchhean import LocalAuthentication -
sourleangchhean168 revised this gist
Jan 31, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ //Noted: This code is written in Swift 5.1 import LocalAuthentication //Mark: BiometricType for define type -
sourleangchhean168 created this gist
Jan 31, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import LocalAuthentication //Mark: BiometricType for define type enum BiometricType{ case touchID case faceID case none } func getBiometricThisDevice() -> BiometricType{ let authContext = LAContext() let _ = authContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) switch (authContext.biometryType){ case .faceID: return .faceID case .touchID: return .touchID default: return .none } } // Mark: How to use it in SwiftUI struct ContentView: View { var body: some View { Text("This device support \(getBiometricThisDevice() == .faceID ? "FaceID" : "Touch ID")") } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }