BackgroundGeolocation promise only fires once

Hello,

Hopefully someone as come across this before.

I’m using the Ionic Native BackgroundGeolocation plugin (cordova-plugin-mauron85-background-geolocation), but I’m having an issue where I only see a location change fire once. The code which prints to the console under the configuration promise only fires when the application is first launched, I can see in Xcode that the background plugin is updating though, but the JS promise is never triggered.

I’m importing my class in the app.ts file:

import { BackgroundLocation } from ‘./providers/background-location/background-location’;

@Component({
templateUrl: ‘build/app.html’,
providers:[ BackgroundLocation]
})
class MyApp {
@ViewChild(Nav) nav: Nav;

rootPage: any = LoginPage;

pages: Array<{ title: string, component: any }>

constructor(private platform: Platform, public bgLocation: BackgroundLocation) {
this.initializeApp();

// used for an example of ngFor and navigation
this.pages = [
  { title: 'Members', component: MembersPage },
  { title: 'Settings', component: SettingsPage }
];

}

initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();

});

}

I’m just using the example code form the Ionic documentation:

let config = {
        desiredAccuracy: 10,
        stationaryRadius: 20,
        distanceFilter: 30,
        debug: true, //  enable this hear sounds for background-geolocation life-cycle.
        stopOnTerminate: false, // enable this to clear background location settings when the app terminates
};

BackgroundGeolocation.configure((location) => {
     console.log('[js] BackgroundGeolocation callback:  ' + location.latitude + ',' + location.longitude);
      
      BackgroundGeolocation.finish(); // FOR IOS ONLY

 }, (error) => {
   console.log('BackgroundGeolocation error');
 }, {
  //options
});

// Turn ON the background-geolocation system.  The user will be tracked whenever they suspend the app.
BackgroundGeolocation.start();

}

// If you wish to turn OFF background-tracking, call the #stop method.
BackgroundGeolocation.stop();

Any ideas?

Thanks

How are you changing your position? If you don’t move past the range, I believe the event will not refire.

Chris

I’ve got it running under the Xcode simulator at the moment using the Freeway Drive.

I have the exact same problem with the same cordova plugin and ionic native.

Have you been able to solve it?

Just like you, when my app is running in background (using Android 6.X on a real cellphone), the callback function is never “called back”. When I take a look at the “notifications”, the message “Background Geolocation running” appear.

I’ve also tried to use the Cordova-Background-Mode and exactly the same problem.

Can someone help us?

Thanks!