transistorsoft / flutter_background_geolocation

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

Running geolocation without geofence #1322

Open csongorkeller opened 2 weeks ago

csongorkeller commented 2 weeks ago

I'm using the plugin for a very simple walk-tracking feature. And it all works correctly when the user is moving. But when it stopped for a longer time, the plugin goes in geofence mode correctly, which I want to bypass entirely. I want to avoid going into that state entirely. Ideally the app just keeps tracking without any geofence even if the user had not moved. Can I achieve it somehow?

This is my config:

void _configureBackgroundGeolocation() async { //Configure the plugin bg.BackgroundGeolocation.ready(bg.Config( reset: false, // <-- lets the Settings screen drive the config rather than re-applying each boot. // Convenience option to automatically configure the SDK to post to Transistor Demo server. // transistorAuthorizationToken: token, // Logging & Debug debug: false, logLevel: bg.Config.LOG_LEVEL_VERBOSE, // Geolocation options desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH, distanceFilter: Navigation.distanceFilter, speedJumpFilter: Navigation.speedJumpFilter, // Activity recognition options stopTimeout: 3, backgroundPermissionRationale: bg.PermissionRationale( title: "Allow {applicationName} to access this device's location even when the app is closed or not in use.", message: "This app collects location data to enable recording your trips to work and calculate distance-travelled.", positiveAction: 'Change to "{backgroundPermissionOptionLabel}"', negativeAction: 'Cancel'), stopOnTerminate: true, startOnBoot: false, enableHeadless: false, foregroundService: true, heartbeatInterval: Navigation.heartbeatInterval)) .then((bg.State state) async { print('[ready] ${state.toMap()}'); print('[didDeviceReboot] ${state.didDeviceReboot}'); if (state.schedule!.isNotEmpty) { bg.BackgroundGeolocation.startSchedule(); } }).catchError((error) { print('[ready] ERROR: $error'); }); }

christocracy commented 2 weeks ago

See api docs Config.stopTimeout. You are free to use a really large number.