Skip to content

Commit

Permalink
Fix incorrect non determined status hanling as incorrect for one shot…
Browse files Browse the repository at this point in the history
… request
  • Loading branch information
abakhtin committed Nov 30, 2020
1 parent 3d16166 commit 5cf11b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/SwiftLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class GPSController: UIViewController, UITableViewDelegate, UITableViewDataSourc
let request = SwiftLocation.gpsLocationWith(serviceOptions)

serviceOptions = GPSLocationOptions()
serviceOptions.avoidRequestAuthorization = true
reloadData()

AppDelegate.attachSubscribersToGPS([request])
Expand Down

0 comments on commit 5cf11b5

Please sign in to comment.