import { BackgroundGeolocation, BackgroundGeolocationConfig, BackgroundGeolocationEvents, BackgroundGeolocationResponse } from '@awesome-cordova-plugins/background-geolocation/ngx';
constructor(private backgroundGeolocation: BackgroundGeolocation) { }
...
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true,
stopOnTerminate: false,
};
this.backgroundGeolocation.configure(config)
.then(() => {
this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
console.log(location);
this.backgroundGeolocation.finish();
});
});
this.backgroundGeolocation.start();
this.backgroundGeolocation.stop();