Required Reading
Plugin Version
flutter_background_geolocation: ^4.16.9
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
ALl
Device operating-systems(s)
All
What do you require assistance about?
What we want is that we need location on every 15 min or user walk to distance 250 meter but we are getting location frequently in 1-2 sec or some time in 2-3 hrs. and we are getting location after stop service in release mode. So please help us if we need to set other configuration or need to change in code.
[Optional] Plugin Code and/or Config
// Fired whenever a location is recorded
bg.BackgroundGeolocation.onLocation((bg.Location location) {
print('[location] - $location');
});
// Fired whenever the plugin changes motion-state (stationary->moving and vice-versa)
bg.BackgroundGeolocation.onMotionChange((bg.Location location) {
print('[motionchange] - $location');
print("[onMotionChange] isMoving? ${location.isMoving}");
});
// Fired whenever the state of location-services changes. Always fired at boot
bg.BackgroundGeolocation.onProviderChange((bg.ProviderChangeEvent event) {
print('[providerchange] - $event');
});
bg.BackgroundGeolocation.onHttp((bg.HttpEvent event) {
print('[${bg.Event.HTTP}] - $event');
print('[http] success? ${event.success}, status? ${event.status}');
});
bg.BackgroundGeolocation.onConnectivityChange(
(bg.ConnectivityChangeEvent event) {
print('[connectivitychange] - $event');
});
bg.BackgroundGeolocation.onSchedule((bg.State state) {
print('[${bg.Event.SCHEDULE}] - $state');
});
// bg.BackgroundGeolocation.destroyLocation((String uuid) {
// print('[${bg.Event.SCHEDULE}] - $state');
// });
// Configure the plugin
bg.BackgroundGeolocation.ready(
bg.Config(
locationAuthorizationRequest: 'Always',
disableLocationAuthorizationAlert: false,
disableMotionActivityUpdates: false,
// backgroundPermissionRationale: bg.PermissionRationale(
// title: "Give me Location bro",
// message: "I want you for testing",
// positiveAction: "Click here",
// negativeAction: "Don't click here"),
// stationaryRadius: 200,
// minimumActivityRecognitionConfidence: 75,
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 250,
// Set distance filter to 100 meters
disableElasticity: true,
preventSuspend: true,
stopOnTerminate: false,
startOnBoot: true,
debug: false,
logLevel: bg.Config.LOG_LEVEL_VERBOSE,
foregroundService: true,
forceReloadOnLocationChange: true,
geofenceModeHighAccuracy: true,
forceReloadOnGeofence: true,
forceReloadOnMotionChange: true,
isMoving: true,
locationUpdateInterval: 600000,
enableHeadless: true,
showsBackgroundLocationIndicator: false,
stopOnStationary: false,
pausesLocationUpdatesAutomatically: false,
schedule: [],
//new
heartbeatInterval: 60,
// autoSyncThreshold: 5,
// batchSync: true,
// maxBatchSize: 10,
// Server endpoint
url: Common.domain + "XXXX",
// Authorization header
headers: header,
// Parameters to send with each location
params: {'EmpCode': widget.employeecode},
// extras: {
// "trackingId": trackingID,
// },
// Sync and HTTP settings
autoSync: true,
// Automatically send locations to the server
method: 'POST', // HTTP POST method
),
).then((bg.State state) async {
if (!state.enabled) {
// Start the plugin if it's not already running
// await bg.BackgroundGeolocation.stop();
// await bg.BackgroundGeolocation.start();
print(bg.Location);
print("hereee.....");
}
// await bg.BackgroundGeolocation.stop();
});
[Optional] Relevant log output
Required Reading
Plugin Version
flutter_background_geolocation: ^4.16.9
Mobile operating-system(s)
Device Manufacturer(s) and Model(s)
ALl
Device operating-systems(s)
All
What do you require assistance about?
What we want is that we need location on every 15 min or user walk to distance 250 meter but we are getting location frequently in 1-2 sec or some time in 2-3 hrs. and we are getting location after stop service in release mode. So please help us if we need to set other configuration or need to change in code.
[Optional] Plugin Code and/or Config
[Optional] Relevant log output