Required Reading
Plugin Version
4.19.4
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
Google pixel 9
Device operating-systems(s)
Android 16
React Native / Expo version
0.83.9
What do you require assistance about?
Background
Our app uses the .onGeofence event handler (via .startGeofences()) to detect when devices leave geofences.
When a geofence exit event occurs, the following is performed:
- Await an HTTP request for conditional logic
- If the conditions are met, trigger a local notification
This works flawlessly on iOS devices. However, on Android devices it does not work while the app is in the background. (For the terminated state, I have implemented a headless task, and that works flawlessly as well.)
Instead, this is what happens on Android:
- The geofence exit event is triggered (verified via logs)
- Then nothing happens
- The next time the app returns to the foreground, the HTTP request executes and the notification is triggered
If I remove the HTTP request, the notifications are sent immediately as expected. It seems that long-running async tasks are being queued rather than executed while the app is in the background. Short synchronous work behaves as expected.
I have also tried using .startBackgroundTask, but that task is likewise only executed once the app returns to the foreground.
Questions
- Is this a known behavior?
- Any ideas why this happens and how (or if) it can be fixed?
[Optional] Plugin Code and/or Config
[Optional] Relevant log output
Required Reading
Plugin Version
4.19.4
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
Google pixel 9
Device operating-systems(s)
Android 16
React Native / Expo version
0.83.9
What do you require assistance about?
Background
Our app uses the .onGeofence event handler (via .startGeofences()) to detect when devices leave geofences.
When a geofence exit event occurs, the following is performed:
This works flawlessly on iOS devices. However, on Android devices it does not work while the app is in the background. (For the terminated state, I have implemented a headless task, and that works flawlessly as well.)
Instead, this is what happens on Android:
If I remove the HTTP request, the notifications are sent immediately as expected. It seems that long-running async tasks are being queued rather than executed while the app is in the background. Short synchronous work behaves as expected.
I have also tried using .startBackgroundTask, but that task is likewise only executed once the app returns to the foreground.
Questions
[Optional] Plugin Code and/or Config
[Optional] Relevant log output