Is there any way to check that service is already running or not like I can see the log
⚠️ #ready already called. Redirecting to #setConfig
I am calling below things in initState
bg.BackgroundGeolocation.onLocation(_onLocation, _onLocationError);
bg.BackgroundGeolocation.onMotionChange(_onMotionChange);
bg.BackgroundGeolocation.onActivityChange(_onActivityChange);
bg.BackgroundGeolocation.onProviderChange(_onProviderChange);
bg.BackgroundGeolocation.onConnectivityChange(_onConnectivityChange);
bg.BackgroundGeolocation.onHttp(_onHttp);
bg.BackgroundGeolocation.onAuthorization(_onAuthorization);
////
// 2. Configure the plugin
//
await bg.BackgroundGeolocation.ready(
bg.Config(
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 50,
stopOnTerminate: false,
startOnBoot: true,
debug: false,
enableHeadless: true,
autoSync: true,
autoSyncThreshold: 5,
batchSync: true,
maxBatchSize: 50,
locationsOrderDirection: 'ASC',
maxDaysToPersist: 30,
pausesLocationUpdatesAutomatically: false,
// activityRecognitionInterval: 10000,
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',
),
logLevel: bg.Config.LOG_LEVEL_VERBOSE,
url: 'https://abc-api.preview.im/api/v1/client/locations',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Authorization': 'Bearer $token',
},
),
).then((bg.State state) async {
log('[ready] ${state.toMap()}');
if (!state.enabled) {
////
// 3. Start the plugin.
//
await bg.BackgroundGeolocation.start();
// await bg.BackgroundGeolocation.sync();
}
}).catchError((error) {
log('[ready] ERROR: $error');
});
Is there any way to check that service is already running or not like I can see the log
⚠️ #ready already called. Redirecting to #setConfig
I am calling below things ininitState