icapps / flutter-background-location-tracker

Flutter background location tracker plugin. (Android / iOS)
MIT License
31 stars 37 forks source link

No tracking when in background #71

Open remoteportal opened 12 months ago

remoteportal commented 12 months ago

I see that if the example app is not in the foreground (the background), I continue to get notifications.

But as I close the app the notifications stop.

ikbendewilliam commented 8 months ago

You need to set the location permission to "always allow". This is not something an app can request and in a production app you should show a dialog to the user and open settings for them.

zwells commented 7 months ago

After setting "always allow", does this plugin work on iOS when the app is terminated? i.e. when the 500 meter threshold is passed, does it wake up the app with our callback?

Reference: https://developer.apple.com/documentation/corelocation/cllocationmanager/1423531-startmonitoringsignificantlocati

12people commented 7 months ago

@ikbendewilliam Even with that setting enabled, it doesn't work for me.

To reproduce:

  1. Install the example app on an iOS emulator (I use iOS 17.4 on iPhone SE 3rd gen, but I assume any modern emulator will do)
  2. In the emulator's Features > Location menu, choose Freeway Ride
  3. Enable the "always" location setting in iOS Settings
  4. Open the example app
  5. Start tracking location
  6. Open the iOS app overview
  7. Swipe the example app away

Expected result:

Actual result:

zwells commented 7 months ago

I made a pull request on a different repo that achieves this: https://github.com/Almoullim/background_location/pull/207

12people commented 7 months ago

There's also flutter_location_wakeup that seems to do this.

Would be good to have it in one add-on, though. And perhaps there's even a better way to achieve this in general?

The perfect solution for my use case would be a native geofencing plug-in that works reliably in the background.