Skip to content

Commit

Permalink
Return completion data when requesting temporary full accuracy permis…
Browse files Browse the repository at this point in the history
…sions (#20)

* Returns the completion closure's error or the updated accuracyAuthorization as a future

* Callback with AccuracyAuthorization

* Small tweaks

* infer

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
tomhut and stephencelis authored Mar 22, 2022
1 parent 198e936 commit 95d45d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Sources/ComposableCoreLocation/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ public struct LocationManager {

public var requestWhenInUseAuthorization: () -> Effect<Never, Never>

public var requestTemporaryFullAccuracyAuthorization:
(String)
-> Effect<Never, Never>
public var requestTemporaryFullAccuracyAuthorization: (String) -> Effect<Never, Error>

public var set: (Properties) -> Effect<Never, Never>

Expand Down
14 changes: 11 additions & 3 deletions Sources/ComposableCoreLocation/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,21 @@ extension LocationManager {
}
},
requestTemporaryFullAccuracyAuthorization: { purposeKey in
.fireAndForget {
.run { subscriber in
#if (compiler(>=5.3) && !(os(macOS) || targetEnvironment(macCatalyst))) || compiler(>=5.3.1)
if #available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, macCatalyst 14.0, *) {
manager
.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey)
manager.requestTemporaryFullAccuracyAuthorization(
withPurposeKey: purposeKey
) { error in
subscriber.send(completion: error.map { .failure(.init($0)) } ?? .finished)
}
} else {
subscriber.send(completion: .finished)
}
#else
subscriber.send(completion: .finished)
#endif
return AnyCancellable {}
}
},
set: { properties in
Expand Down

0 comments on commit 95d45d7

Please sign in to comment.