Cordova-plugin-background-geolocation: Geolocation stop after 5 minutes on background

Created on 14 Oct 2019  路  3Comments  路  Source: mauron85/cordova-plugin-background-geolocation

Your Environment


  • Plugin version: 3.1.0
  • Platform: Android
  • Cordova version: 9.0.1
  • Cordova platform version (cordova platform ls): android 8.1.0

Context

Get positions with app in background

Expected Behavior

Get positions with app in background

Actual Behavior

The position stop after 5 minutes

Configs

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);
}
}

Most helpful comment

I am facing the same issue

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivent picture ivent  路  7Comments

netbitsolutions picture netbitsolutions  路  10Comments

ThorvaldAagaard picture ThorvaldAagaard  路  9Comments

n0minal picture n0minal  路  10Comments

shyamal890 picture shyamal890  路  10Comments