Skip to content

Commit

Permalink
Adds optional setting to require precise accuracy (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk authored May 28, 2023
1 parent 03f3cab commit 18fcf08
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/GeoMonitor/GeoMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public class GeoMonitor: NSObject, ObservableObject {
private var monitorTask: Task<Void, Error>? = nil

public var maxRegionsToMonitor = 20

/// Set to `true` if the `hasAccuracy` values should also check whether the user
/// has provided access to the full accuracy/
public var needsFullAccuracy: Bool = false

/// Instantiates new monitor
/// - Parameters:
Expand Down Expand Up @@ -138,12 +142,12 @@ public class GeoMonitor: NSObject, ObservableObject {
private func updateAccess() {
switch locationManager.authorizationStatus {
case .authorizedAlways:
hasAccess = true
hasAccess = !needsFullAccuracy || locationManager.accuracyAuthorization == .fullAccuracy
// Note: We do NOT update `enableInBackground` here, as that's the user's
// setting, i.e., they might not want to have it enabled even though the
// app has permissions.
case .authorizedWhenInUse:
hasAccess = true
hasAccess = !needsFullAccuracy || locationManager.accuracyAuthorization == .fullAccuracy
enableInBackground = false
case .denied, .notDetermined, .restricted:
hasAccess = false
Expand Down

0 comments on commit 18fcf08

Please sign in to comment.