cordova platform ls): android 8.1.0Get positions with app in background
Get positions with app in background
The position stop after 5 minutes
function GeolocationConfiguration() {
BackgroundGeolocation.configure({
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 1,
distanceFilter: 1,
notificationTitle: 'Multivision',
notificationText: 'Posicionamento em background ativo',
debug: false,
interval: 15000,
fastestInterval: 20000,
activitiesInterval: 15000,
stopOnTerminate: true,
startForeground: true,
startOnBoot: true,
activityType: 'Other',
url: '',
httpHeaders: {
'Content-Type': 'application/json'
},
postTemplate: {
lat: '@latitude',
lon: '@longitude',
time: '@time'
}
});
BackgroundGeolocation.start();
}
function GetPosition(){
try {
BackgroundGeolocation.getCurrentLocation(locations => {
var position = {
latitude: locations.latitude,
longitude: locations.longitude
};
monitoramento.GeolocationSuccess(position);
}, monitoramento.GeolocationError);
monitoramento.bgInterval = setTimeout(function () { monitoramento.GetPosition(); }, monitoramento.tempoDaCoisaToda);
} catch (err) {
monitoramento.MostraLog("", "Error: " + JSON.stringify(err));
monitoramento.bgInterval = setTimeout(function () { monitoramento.GetPosition(); }, monitoramento.tempoDaCoisaToda);
}
}
I am facing the same issue
I had this same issue, and was able to resolve it by configuring my device settings according to https://dontkillmyapp.com/, as Samsung's "nifty battery optimizing mode" was pausing the background service which disabled location updates
@bhammack didn't work for me. My app does get location updates in the background indefinitely, but it does not store those in the the local-db, nor does it post with ajax to the server.
@bhammack
What version of Android/Plugin are you using?
Android Version: 8.0.1
Plugin Version: 3.1.0
SAMSUNG-SM-J727V
Most helpful comment
I am facing the same issue