Skip to content

Listeners not being called in background (when app is closed) #60

Description

@Jonny1987

I have done the following, I want to send location data to my backend when the app is closed, and while event listeners get called when the app is open or minimised, they don't get called when the app is closed.

The docs say "Add event listeners outside of your view lifecycle if you want them to work when the app is in the background.", and I have tried putting this code in different places, calling from the app's main method, the initState of the home page or from a riverpod provider, but none of them work when the app is closed.

  @pragma('vm:entry-point')
  static void onLocation(Map result) {
    print('onLocation');
    sendLocationToBackend(result);
  }

  Radar.attachListeners();
  Radar.onLocation(onLocation);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions