Skip to content

Fix notifications and enable background data fetch while app is not focused. - #195

Merged
stopflock merged 3 commits into
FoggedLens:mainfrom
reb1995:add-notifications-android-and-background-fixes
Sep 4, 2026
Merged

Fix notifications and enable background data fetch while app is not focused.#195
stopflock merged 3 commits into
FoggedLens:mainfrom
reb1995:add-notifications-android-and-background-fixes

Conversation

@reb1995

@reb1995 reb1995 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Based on the branch that @kferland opened in #183.

Updated to fix notifications on real Android hardware.

Added a location bounding box that keeps track of where the user is, even when the app in not focused. When you get close to the edge of that bounding box, it will download data around the current position, update the camera cache, and then update the bounding box regions.

This was required because previously the data only downloaded when the app was focused.

Only tested on Pixel 10 Pro. Have not tested on iOS, however initial branch showed it working in an emulator.

Fixes known issue of notifications not working in general and potentially #184.

JKFerland and others added 3 commits August 27, 2026 10:55
…st location refresh.

Tested on a Pixel 10 Pro. These changes were needed to work on real hardware. Also, which background location updating was working, the data was not refreshing in the background. This also adds that. It will pull nodes in a 5km area around your location and update when you within 1km of the area. These values may need to be adjusted if there is increased load on the servers.
- Increase background refresh threshold: Raised the edge distance check in GpsController from 1000m to 2500m to guarantee new Overpass data is fetched well before the user drives out of the cached bounding box.

- Fix bounding box race condition: Added await to the background fetch handler in MapView so tracking bounds only shift forward after the network request successfully finishes.

- Make debounced fetches awaitable: Refactored fetchAndUpdate in NodeProviderWithCache to return a Future<void> using a Completer, bridging the 400ms debounce timer.

- Prevent hanging futures: Added state checks for _activeCompleter to instantly resolve canceled network requests during rapid map panning, preventing fatal StateError crashes and infinite UI hangs.
@reb1995 reb1995 changed the title Fix notifications for Android and enable background data fetch while app is not focused. Fix notifications and enable background data fetch while app is not focused. Aug 28, 2026

@stopflock stopflock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has worked for me in testing. Merging.


class _ProximityAlertsSectionState extends State<ProximityAlertsSection> {
class _ProximityAlertsSectionState extends State<ProximityAlertsSection>
with WidgetsBindingObserver {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this indentation weird or am I crazy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not checking the math here but will try to test at the extremes

@stopflock
stopflock merged commit 1423897 into FoggedLens:main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants