Merge pull request #58 from TouchInstinct/feature/biometry_type

Add BiometryType for BiometricsService
This commit is contained in:
Ivan Zinovyev 2019-01-25 15:49:24 +03:00 committed by GitHub
commit e42fece1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 13 deletions

View File

@ -1,5 +1,10 @@
# Changelog
### 0.3.10
- **Remove**: `isTouchIdSupported` and `isFaceIdSupported`.
- **Add** BiometryType for BiometricsService: `touchID`, `faceID`, `none`.
### 0.3.9
- **Add**: `allowableReuseDuration` variable to `BiometricsService` which is a wrapper for touchIDAuthenticationAllowableReuseDuration.

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKitAdditions"
s.version = "0.3.9"
s.version = "0.3.10"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKitAdditions"
s.license = "Apache License, Version 2.0"

View File

@ -26,6 +26,15 @@ public typealias BiometricsAuthHandler = (Bool, Error?) -> Void
/// Service that provide access to authentication via biometric
public final class BiometricsService {
public enum BiometryType {
case faceID
case touchID
case none
}
private lazy var laContext = LAContext()
@ -43,21 +52,22 @@ public final class BiometricsService {
}
}
/// Returns true if user can authenticate via Face ID
public var isFaceIdSupported: Bool {
if #available(iOS 11.0, *) {
return canAuthenticateWithBiometrics && laContext.biometryType == .faceID
}
return false
}
/// Returns true if user can authenticate via Touch ID
public var isTouchIdSupported: Bool {
/// Returns BiometryType supporting by device: TouchID, FaceID or none
public var biometryType: BiometryType {
let canEvaluate = canAuthenticateWithBiometrics
if #available(iOS 11.0, *) {
return canEvaluate && laContext.biometryType == .touchID
switch laContext.biometryType {
case .touchID:
return .touchID
case .faceID:
return .faceID
case .none:
return .none
}
}
return canEvaluate
return canEvaluate ? .touchID : .none
}
/// Returns current domain state