From 5cf11b59f32fdb812f79ec9264122c1ddbd2ed32 Mon Sep 17 00:00:00 2001 From: Alexey Bakhtin Date: Mon, 30 Nov 2020 20:53:10 +0300 Subject: [PATCH 1/2] Fix incorrect non determined status hanling as incorrect for one shot request --- .../Extensions/CLLocationManager+Extension.swift | 9 +++++++++ Sources/SwiftLocation/SwiftLocation.swift | 2 +- .../Features/Location by GPS/GPSController.swift | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftLocation/Extensions/CLLocationManager+Extension.swift b/Sources/SwiftLocation/Extensions/CLLocationManager+Extension.swift index 61597dd0..02b3b339 100644 --- a/Sources/SwiftLocation/Extensions/CLLocationManager+Extension.swift +++ b/Sources/SwiftLocation/Extensions/CLLocationManager+Extension.swift @@ -146,6 +146,15 @@ extension CLAuthorizationStatus: CustomStringConvertible { return false } } + + internal var isRejected: Bool { + switch self { + case .denied, .restricted: + return true + default: + return false + } + } public var description: String { switch self { diff --git a/Sources/SwiftLocation/SwiftLocation.swift b/Sources/SwiftLocation/SwiftLocation.swift index d3457d37..cdab8932 100644 --- a/Sources/SwiftLocation/SwiftLocation.swift +++ b/Sources/SwiftLocation/SwiftLocation.swift @@ -551,7 +551,7 @@ public class LocationManager: LocationManagerDelegate, CustomStringConvertible { } private func failWeakAuthorizationRequests() { - guard authorizationStatus.isAuthorized == false else { + guard authorizationStatus.isRejected == true else { // If we have already the authorization even request with `avoidRequestAuthorization = true` // may receive notifications of locations. return diff --git a/SwiftLocationPlayground/SwiftLocationPlayground/View Controllers/Features/Location by GPS/GPSController.swift b/SwiftLocationPlayground/SwiftLocationPlayground/View Controllers/Features/Location by GPS/GPSController.swift index 368a2b64..f1e87e3e 100644 --- a/SwiftLocationPlayground/SwiftLocationPlayground/View Controllers/Features/Location by GPS/GPSController.swift +++ b/SwiftLocationPlayground/SwiftLocationPlayground/View Controllers/Features/Location by GPS/GPSController.swift @@ -232,6 +232,7 @@ class GPSController: UIViewController, UITableViewDelegate, UITableViewDataSourc let request = SwiftLocation.gpsLocationWith(serviceOptions) serviceOptions = GPSLocationOptions() + serviceOptions.avoidRequestAuthorization = true reloadData() AppDelegate.attachSubscribersToGPS([request]) From eb2f85631a6e37117471300375b1c1fcb004b46a Mon Sep 17 00:00:00 2001 From: Daniele Margutti Date: Sun, 6 Dec 2020 10:12:06 +0100 Subject: [PATCH 2/2] Bump to 5.0.2 podspec --- SwiftLocation.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftLocation.podspec b/SwiftLocation.podspec index a21d7b2a..80b33afb 100644 --- a/SwiftLocation.podspec +++ b/SwiftLocation.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SwiftLocation" - s.version = "5.0.1" + s.version = "5.0.2" s.summary = "Location Manager Made Easy" s.description = <<-DESC Efficient location tracking for iOS with support for oneshot/continuous/background tracking, reverse geocoding, autocomplete, geofencing, beacon monitoring & broadcasting