feat: Added Notifications to app - #183
Conversation
| /// background delivery is armed (or dropped) immediately rather than at the | ||
| /// next unrelated stream restart. | ||
| void updateProximityAlertsEnabled(bool enabled) { | ||
| if (_positionSub == null || _streamIsBackgroundCapable == enabled) return; |
There was a problem hiding this comment.
Had to change this line to the below. Otherwise, the foreground location notification never showed up on a real device.
if (_streamIsBackgroundCapable == enabled) return;
|
Also, do we want to change the title/description to something specifying that it is constant location access and proximity alerts? |
|
Was able to test in the real world. Found an issue. The proximity alerts only when trigger on known nodes. If you open the and the zoom is tighter than your drive, you will never alert on new nodes. The location tracking logic works, but alerts do not work. Opening the app from the background will correctly display your current location, refresh the data, and then instantly alerts. We need to refresh node data in the background as well, but at a reasonable rate so we don't DDOS anybody. |
|
Opened up a pull on @JKFerland's feature branch that should solve these issues and make it complete as far as Android is concerned. Basically, 5km of data is downloaded at once. If we come within 1km of that bounding area, we update with another 5km square of data. This is done in the background based on our location. |
|
What's the status on this? Still draft? Ready for review? How much testing has been done? |


Proximity alerts: fire while the app is backgrounded
Brought to you by Claude ™️
Proximity alerts previously only worked with the app open on screen, and on iOS
they never fired at all. This fixes both.
New permissions / entitlements
This PR declares new platform capabilities. Both are worth a look during review.
iOS (
ios/Runner/Info.plist)UIBackgroundModes→location— new key. Without it iOS suspends the app the moment it leaves the screen, which stops the CoreLocation stream and makes a backgrounded alert impossible. This is theentitlement that triggers App Store review scrutiny on background location, so expect to justify it.
NSLocationAlwaysUsageDescription— new usage string covering the background case.NSLocationAlwaysAndWhenInUseUsageDescriptionandNSLocationWhenInUseUsageDescriptionwere already present andare unchanged.
Android (
android/app/src/main/AndroidManifest.xml)FOREGROUND_SERVICE— required to run geolocator'sGeolocatorLocationService, which is what keeps location flowing while backgrounded.FOREGROUND_SERVICE_LOCATION— required from Android 14 onward for a foreground service of typelocation.WAKE_LOCK— without it the system sleeps and delivers queued positions in one burst on wake, far too late to warn anyone about a device they already drove past.ACCESS_BACKGROUND_LOCATIONis deliberately not declared — see the Android section below for why.ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,POST_NOTIFICATIONSandINTERNETwere already declared and are unchanged.Changes
Background operation
locationbackground mode toInfo.plist. Without it iOS suspends the app the moment it leaves the screen, which stops the CoreLocation stream and makes a backgrounded alertimpossible.
AppleSettingswithallowBackgroundLocationUpdates. It's armed only while the user has proximity alerts switched on, so everyone else keeps the oldforeground-only behavior and no blue status bar pill.
pauseLocationUpdatesAutomatically: false. iOS otherwise pauses updates once it decides you've stopped moving and never reliably resumes them, silently killing alerts mid-trip.visibleBounds. The camera is frozen wherever you left it while backgrounded, so a viewport lookup returnednodes from wherever you were miles ago — this also fixes missed alerts in the foreground when the map is panned away from you.
iOS notifications (previously fully broken)
UNUserNotificationCenter.delegateinAppDelegate.flutter_local_notificationsimplementswillPresentbut never registers itself, so iOS was silently suppressing every foregroundnotification.
initialize()'s return value. On iOS that reports the outcome of the permission request — which we intentionally disable — so it returnedfalseeven on successand left every notification path dead.
presentBanner/presentListto the Darwin notification details.presentAlertalone is dead on iOS 14+, where the plugin only consults the other two, so no banner ever appeared.ArgumentErrorand dropped the notification entirely.areNotificationsEnabled()now actually asks iOS instead of returning a blindtrue. The settings UI previously couldn't tell whether notifications were authorized.remaining path. Localized across all 11 locales.
Tests
test/services/geo_bounds_test.dart. Covers the location-boxing math in real meters, including thecos(latitude)longitude widening and clamping at the poles and antimeridian.test/services/notification_id_test.dart. Pins the 32-bit contract against real OSM node IDs, negative (not-yet-uploaded) IDs, and determinism so a repeat alert replaces rather than stacks.Video
bob.mov
Platform coverage — iOS only
This was tested on iOS only. The Android path is unverified.