transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
648 stars 239 forks source link

Location tracking stops working after a few days #1080

Closed 4A6F6F6E61 closed 1 year ago

4A6F6F6E61 commented 1 year ago

Your Environment

• No issues found!

* Plugin config:
```dart  <!-- syntax-highligting:  DO NOT REMOVE -->
bg.BackgroundGeolocation.onLocation((bg.Location location) async {
  log('[onLocation] $location');
  final geo = GeoFlutterFire();
  currentLocation.value = location; // this is saving the current location in my GetX state
  GeoFirePoint myLocation =
      geo.point(latitude: location.coords.latitude, longitude: location.coords.longitude);
  placemarkFromCoordinates(location.coords.latitude, location.coords.longitude,
          localeIdentifier: Get.locale?.countryCode ?? "en_US")
      .then((value) {
    log(placemarks.toString());
    placemarks(value);  // this is saving the placemark in my GetX state
  });
  if (auth.currentUser != null) {
    firebaseFirestore
        .collection('users')
        .doc(auth.currentUser!.uid)
        .update({'position': myLocation.data});
  }
}, (bg.LocationError error) {
  log('[onLocation] ERROR - $error');
});
var state = await bg.BackgroundGeolocation.ready(
  bg.Config(
    desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
    distanceFilter: 10.0,
    stopOnTerminate: false,
    startOnBoot: true,
    enableHeadless: true,
    debug: true,
    logLevel: bg.Config.LOG_LEVEL_DEBUG,
  ),
);
if (!state.enabled) {
  await bg.BackgroundGeolocation.start();
}

Expected Behaviour

The App should keep fetching the current location

Actual Behaviour

The App fetches my location 1-3 times at the start of my App, but then just silently stops. My location doesn't update anymore and I get no [onLocation] printed in the terminal. I don't even get an Error-code or something that would explain why the location tracking stopped. This happened to me before, but after reinstalling MacOS and my DevTools it worked again for a few days. I checked out earlier versions of my App in Git that I know worked in the past, thinking that I may have fucked something up in the latest version but they also don't work.

Steps to Reproduce

  1. Execute my code
  2. wait a few seconds

Context

Fetch the current location and save it as a GeoHash in my Firebase backend

Debug logs

Logs ``` nothing ```
christocracy commented 1 year ago

Plugin version: ^4.8.1

iOS 16.4 made changes. See the CHANGELOG and upgrade to latest

4A6F6F6E61 commented 1 year ago

Thanks for the info, I'll check it out.

4A6F6F6E61 commented 1 year ago

I didn't change my code but all of the sudden the location tracking works again as it should. I am unable to find a reason why it sometimes worked as it should and other times only fetches the location ca 3 times at the start and then just quietly stops. Is there some way to get mote detailed logs from this package like for example why it stopped? My console is just empty when this happens. Help would be greatly appreciated.

christocracy commented 1 year ago

See Wiki "Debugging". The plugin has an incredible logger. learn to use it.

4A6F6F6E61 commented 1 year ago

Thanks, I will use this the next time I encounter this issue!