flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Question]: Ios background stop location updates

Open tarilo opened this issue 1 year ago • 7 comments

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

  • [ ] Android
  • [X] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Your question

Hello. We have integrated your location library but when the app is switched to the background on an iOS device, the interception of positioning changes stops within a few seconds. It works in the foreground but when the app is minimized it stops.

We have followed your example with the following code.

final LocationSettings locationSettings = LocationSettings( accuracy: LocationAccuracy.high, distanceFilter: 100, );

StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen( (Position? position) { print(position == null ? 'Unknown' : 'Geolocator ${position.latitude.toString()}, ${position.longitude.toString()}'); });

info.plist UIBackgroundModes fetch location processing remote-notification

How can we use the library so that, when the application is in the background, it does not constantly send position changes to a server?

Thanks

Version

12.0.0

tarilo avatar Jun 14 '24 12:06 tarilo

same issue.

when app killed in IOS , unable to listen location updates.

mayank-vinove avatar Jun 17 '24 04:06 mayank-vinove

Hi @mayank-vinove

With the app. in background you can listen location changes after 5 secs?

tarilo avatar Jun 17 '24 08:06 tarilo

As per my understanding minimum interval is 15 min but iam unable to get a callback after every ~15 min.

mayank-vinove avatar Jun 17 '24 08:06 mayank-vinove

But there are a multitude of apps with background tracking like Google Maps, Waze, Uber, etc. I think there is a way to be able to track location in the background, for example for interaction with beacons.

tarilo avatar Jun 17 '24 08:06 tarilo

No coments?

tarilo avatar Jun 18 '24 17:06 tarilo

Dear @tarilo,

Can you check if it works as expected in the supplied example app? Also check if you requested the correct permissions and added the correct permission to the pod file. Furthermore, check if you used the correct plist entries.

Kind regards,

TimHoogstrate avatar Jul 29 '24 14:07 TimHoogstrate

@tarilo This plugin does not have any reference to https://developer.apple.com/documentation/corelocation/cllocationmanager/startmonitoringsignificantlocationchanges() which is probably what you are looking for. This is the api that allows terminated apps to start and receive notification changes when the location has changed.

edit: Some new iOS apis support restarting the process when the app is terminated https://github.com/Baseflow/flutter-geolocator/issues/1567

aanelson avatar Aug 08 '24 16:08 aanelson

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] avatar Sep 03 '24 13:09 github-actions[bot]