From c27a031dccafa117f67f879e1691247414b4e615 Mon Sep 17 00:00:00 2001 From: Aliona Date: Wed, 25 Jul 2018 15:46:41 +0300 Subject: [PATCH] Move isFaceIdSupported to Leadkit --- CHANGELOG.md | 4 ++++ LeadKitAdditions.podspec | 2 +- Sources/Services/BiometricsService.swift | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 125494b..a207bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog +### 0.3.4 + +- **Add**: `isFaceIdSupported` variable to `BiometricsService` to distinguish FaceID from TouchID. + ### 0.3.3 - **Add**: Public `init` to `BiometricsService` diff --git a/LeadKitAdditions.podspec b/LeadKitAdditions.podspec index 60dba35..611630a 100644 --- a/LeadKitAdditions.podspec +++ b/LeadKitAdditions.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKitAdditions" - s.version = "0.3.3" + s.version = "0.3.4" 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" diff --git a/Sources/Services/BiometricsService.swift b/Sources/Services/BiometricsService.swift index 31e1030..90a91d5 100644 --- a/Sources/Services/BiometricsService.swift +++ b/Sources/Services/BiometricsService.swift @@ -29,6 +29,16 @@ public final class BiometricsService { private lazy var laContext = LAContext() + /// Returns true if user can authenticate via faceID + public var isFaceIdSupported: Bool { + if #available(iOS 11.0, *) { + return laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) + && laContext.biometryType == .faceID + } else { + return false + } + } + /// Returns current domain state public var evaluatedPolicyDomainState: Data? { // We need to call canEvaluatePolicy function for evaluatedPolicyDomainState to be updated