Skip to content

Commit 2d0f7d6

Browse files
committed
Update Permission.swift
1 parent 9153e06 commit 2d0f7d6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Sources/d3-async-location/LocationManagerAsync+/Permission.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ extension LocationManagerAsync{
4444
initSubscription()
4545
}
4646

47-
/// resume continuation if it was not called
47+
/// resume continuation if it was not called with status .notDetermined
4848
deinit {
49-
flow?.resume(returning: .notDetermined)
50-
flow = nil
49+
resume(with: .notDetermined)
5150
}
5251

5352
// MARK: - API
@@ -62,7 +61,6 @@ extension LocationManagerAsync{
6261

6362
// MARK: - Private methods
6463

65-
6664
/// Subscribe for event when location manager change authorization status to go on access permission flow
6765
private func initSubscription(){
6866
let name = Permission.authorizationStatus
@@ -77,10 +75,16 @@ extension LocationManagerAsync{
7775
private func statusChanged(_ value: Output) {
7876
if let s = value.object as? CLAuthorizationStatus{
7977
status = s
80-
flow?.resume(returning: status)
81-
flow = nil
78+
resume(with: status)
8279
}
8380
}
81+
82+
/// Resume continuation
83+
/// - Parameter status: resume
84+
private func resume(with status : CLAuthorizationStatus) {
85+
flow?.resume(returning: status)
86+
flow = nil
87+
}
8488

8589
/// Requests the user’s permission to use location services while the app is in use
8690
/// Don't forget to add in Info "Privacy - Location When In Use Usage Description" something like "Show list of locations"

0 commit comments

Comments
 (0)