-
Notifications
You must be signed in to change notification settings - Fork 72
Description
First of all, awesome plugin. Now, I understand this is not exactly a plugin's issue, but probably a very common scenario for it.
I'm trying to watch and send the location via HTTP Post request to server as in the following code:
BackgroundGeolocation.addWatcher(
{
backgroundMessage:
"Location is still tracked in background.",
requestPermissions: true,
stale: true,
distanceFilter: 200,
},
async function (location) {
if (location) {
let formData = new FormData();
formData.append("location", JSON.stringify(location));
await ApiService.sendLocation(formData); // Does a simple HTTP post request using Axios.
}
}
);
This is working fine in iOS indefinitely (as long as I grant the 'Always' location permission).
However for Android, this is not the case. I granted all battery/data usage permissions for my app in particular.
After 5 minutes in background, the server will stop receiving locations.
As soon as I enter the app again (it is not being killed btw, I can tell because it does not reload the splash screen) it will start sending all the buffered requests to server.
So the location is being tracked correctly, but it seems like the HTTP requests get blocked and start to pile up.
Does this mean that I should actually do the HTTP request inside the native callback code?
public void onLocationResult(LocationResult locationResult)
I would appreciate any insight, but as I said, I understand this is not precisely this plugin's issue.