Background Geolocation server interaction

Hello All,

I’m using cordova-plugin-mauron85-background-geolocation for fetching the location in the background even when the app is not running in the foreground. What I want to achieve is to get the coordinates of the user and send it or post it to the server for real-time location tracking and updating the DB.
I think the problem is location points are updating in the background but the data is not posted to the server.
Is there any way to interact with the server when the app is not in the foreground.
This is my code:

// Background Tracking
let config: BackgroundGeolocationConfig = {
desiredAccuracy: 0,
stationaryRadius: 20,
distanceFilter: 10,
debug: true,
interval: 2000

.subscribe((location: BackgroundGeolocationResponse) => {

  console.log('BackgroundGeolocation:  ' + location.latitude + ',' + location.longitude);

  // Run update inside of Angular's zone => { = location.latitude;
    this.lng = location.longitude;

  // Server interaction to POST location coordinates.

}, (err) => {

  console.log("ERROR in config", err);


Any help will be highly appreciated.

1 Like

@charlestsmith, did you ever get this working. Struggling with this myself right now. Thx,

@charlestsmith @evandillon This is working for me

let config: BackgroundGeolocationConfig = {
    desiredAccuracy: 10,
    stationaryRadius: 2,
    distanceFilter: 2,
    debug: true,
    interval: 2000,
    stopOnTerminate: false,
    url: "put-the-url-of-file-here",
    postTemplate: {
        lat: '@latitude',
        lng: '@longitude'

this.backgroundGeolocation.configure(config).then((location: BackgroundGeolocationResponse)=>{

Location is sent to server every time it changes when app is in background or foreground.

1 Like

Muchas gracias por la respuesta, voy a probar esto haber q tal, me acabo de dar cuenta q tal cual esta en la documentación, toca leer jajajaja.