react-native-background-geolocation
react-native-background-geolocation copied to clipboard
setConfig does not update extras object
Your Environment
- Plugin version:3.9.3
- Platform: iOS or Android: iOS
- OS version: 15.2
- Device manufacturer / model: iPhone 13 Pro
- React Native version (
react-native -v): 0.63.4 - Plugin config extras
BackgroundGeolocation.setConfig({
schedule: [schedule],
stopAfterElapsedMinutes: totalMinutes,
distanceFilter: trackingConfig.DistanceFilter || 50,
stopTimeout: trackingConfig.TrackingInterval || 3,
method: "POST",
url: nodeURL + 'geoTracking/TrackLocation',
batchSync: false,
autoSync: true,
extras: {
"EmployeeId": userInfo.EmployeeID,
"EmployerId": userInfo.Employerid,
"DeviceUDID": deviceId,
"DeviceType": deviceType,
"TripUDID": tripUDID,
},
}).then((state) => {
console.log("Tracking is configured: ", state.enabled);
BackgroundGeolocation.sync();
});
Expected Behavior
In backend when the api is called, i was expecting the extras object that i am updating in the config.
Actual Behavior
extras is blank like {};
Steps to Reproduce
- Just make the config ready without the extras.
- After its ready display your UI and start the schedule with above code.
- Monitor the backend api.
- Its not having the updated extras object.
Context
I was trying to start the schedule with updated extras object.
Debug logs
Logs
No log i have printed. ``` PASTE_YOUR_LOGS_HERE ```
This problem is always related to having existing location records in the plugin's database attempted to be posted and your server is returning an error, causing the plugin to keep posting that existing first record over and over.
Observe the plugin's logs with adb logcat *:S TSLocationManager:V ReactNativeJS:V ReactNative:V
extras are not updated for existing records in the SQLite database. They are modified only for the next records inserted.
I just did a test. On a button-click, I increment a variable clicks++.
this.clicks++
await BackgroundGeolocation.setConfig({
extras: {
clicks: this.clicks
}
});
// Request a location to invoke an HTTP request
BackgroundGeolocation.getCurrentPosition();
Observing the data on the server, I see extras.clicks incrementing.
Plugin version: 3.9.3
That version dates back to 2020-11-06. I doubt there was a problem with extras in that version, but it is really old and won't support latest Android 12.
I have tried multiple times by deleting the build from the phone as well. Still the result is same and i am not able to get the updated extras. By the way, i am doing startSchedule after doing setConfig.
See wiki Debugging. Configure for verbose logging. call .emailLog and attach the received log file here.
this.clicks++
await BackgroundGeolocation.setConfig({
extras: {
clicks: this.clicks
}
});
// Request a location to invoke an HTTP request
BackgroundGeolocation.getCurrentPosition();
Let me check the same way. Will confirm.
And provide your log file from .emailLog() here.
I’m sure it’s got http errors from your server from the plugin trying over and over again to post already inserted records from before you updated your extras.
existing records inserted into the plug-in’s database are immutable — they will not have their extras updated.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.