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