Skip to content

[Help Wanted]: Android background geofence handler delays async tasks until app returns to foreground #2594

@Licens-ssg

Description

@Licens-ssg

Required Reading

  • Confirmed

Plugin Version

4.19.4

Mobile operating-system(s)

  • iOS
  • Android

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions