Add an async authentication extension to LAContext
This commit is contained in:
parent
b7bbe6acb3
commit
8de53563f7
|
@ -3,7 +3,7 @@
|
|||
// Demo
|
||||
//
|
||||
// Created by Daniel Saidi on 2020-11-30.
|
||||
// Copyright © 2020 Daniel Saidi. All rights reserved.
|
||||
// Copyright © 2020-2022 Daniel Saidi. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftKit
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
# Release notes
|
||||
|
||||
|
||||
## 1.2
|
||||
|
||||
### ✨ New features
|
||||
|
||||
* `LAContext+Async` adds an async policy evaluation function.
|
||||
|
||||
|
||||
|
||||
## 1.1
|
||||
|
||||
### ✨ New features
|
||||
|
@ -16,6 +24,7 @@
|
|||
* `String+UrlEncode` now handles + as well.
|
||||
|
||||
|
||||
|
||||
## 1.0
|
||||
|
||||
I think it's finally time to push the major release button.
|
||||
|
@ -42,6 +51,7 @@ This version also introduces a new `StoreKit` namespace with handy utils for man
|
|||
* `StandardStoreService` is a new class that implements the `StoreService` protocol.
|
||||
|
||||
|
||||
|
||||
## 0.7.0
|
||||
|
||||
This version requires Xcode 13 and later, since it refers to the latest api:s.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// SwiftKit
|
||||
//
|
||||
// Created by Daniel Saidi on 2016-01-18.
|
||||
// Copyright © 2020 Daniel Saidi. All rights reserved.
|
||||
// Copyright © 2016 Daniel Saidi. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// LAContext+Async.swift
|
||||
// SwiftKit
|
||||
//
|
||||
// Created by Daniel Saidi on 2022-04-29.
|
||||
// Copyright © 2016-2022 Daniel Saidi. All rights reserved.
|
||||
//
|
||||
|
||||
import LocalAuthentication
|
||||
|
||||
@available(iOS 15.0, macOS 12.0, *)
|
||||
extension LAContext {
|
||||
|
||||
/**
|
||||
Evaluate a certain policy.
|
||||
|
||||
- Parameters:
|
||||
- policy: The policy to evaluate.
|
||||
- localizedReason: The localized reason to show to the user.
|
||||
*/
|
||||
func evaluatePolicy(_ policy: LAPolicy, localizedReason reason: String) async throws -> Bool {
|
||||
return try await withCheckedThrowingContinuation { cont in
|
||||
LAContext().evaluatePolicy(policy, localizedReason: reason) { result, error in
|
||||
if let error = error { return cont.resume(throwing: error) }
|
||||
cont.resume(returning: result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue