Fix widget distance menu + geofence notification chain
Widget distance menu: the Distance picker only makes sense for Cheapest ordering. It was hidden for Favourites but Closest still showed it (regressed when the per-widget Distance picker was added). parameterSummary now nests When clauses: Distance visible for Cheapest only; Closest and Favourites hide it. Notifications: three compounding defects kept real geofence alerts from ever firing while the app was suspended: 1. Always permission was never properly requested. requestPermissions fired WhenInUse and Always back-to-back; iOS ignores the second call while the first prompt is pending, leaving the app stuck on WhenInUse — and region entries are never delivered in the background. Added locationManagerDidChangeAuthorization to ProximityMonitor: escalate WhenInUse -> Always, and re-register geofences on grant (regions registered under WhenInUse-only won't deliver in the background). 2. The 18-region window was frozen in the background. Re-registration lived in SwiftUI .onChange(of: locationManager.current), which never runs while suspended. Added a delegate hook (LocationManager.onLocationUpdate) fired from didUpdateLocations on every fix including background significant-change wake-ups; the app wires it to re-register geofences around the new position. 3. Region-registration failures were invisible. monitoringDidFailFor was never implemented, so a failed startMonitoring (region budget, auth, radius) silently stopped alerts. Now surfaced as monitor.lastRegionError and shown in Settings -> Debug; cleared on the next successful registration.
This commit is contained in:
@@ -30,8 +30,11 @@ struct SettingsView: View {
|
||||
/// Live snapshot of the device fix + stations in range (from the monitor).
|
||||
var debugStatus: DebugLocationStatus?
|
||||
/// The app's own TOP-badge cheapest (selected fuel + stationLimit radius),
|
||||
/// so the debug "Cheapest in range" row matches the app list exactly.
|
||||
/// passed in so the Debug section mirrors the app list exactly.
|
||||
var appCheapest: DebugAppCheapest?
|
||||
/// Last CoreLocation region-monitoring failure (monitor.lastRegionError).
|
||||
/// Shown in Debug so a silently-failed geofence registration is visible.
|
||||
var regionError: String?
|
||||
|
||||
@StateObject private var tipStore = TipStore()
|
||||
@State private var showTipAlert = false
|
||||
@@ -90,6 +93,11 @@ struct SettingsView: View {
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.green)
|
||||
}
|
||||
if let regionError {
|
||||
Label(regionError, systemImage: "exclamationmark.triangle.fill")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
Button {
|
||||
onPlainTestAlert()
|
||||
} label: {
|
||||
|
||||
Reference in New Issue
Block a user