Hi,
I am trying to add this plugin:
So I am following the docs from ionic:
http://ionicframework.com/docs/v2/native/backgroundgeolocation/.
But it is not working at all.
Simply my code is:
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {BackgroundGeolocation} from 'ionic-native';
import {Observable} from 'rxjs/Observable';
import {Platform} from 'ionic-angular';
@Component({
templateUrl: 'build/pages/about/about.html'
})
export class AboutPage {
public AboutPage:string;
constructor(platform: Platform) {
this.platform = platform;
}
platform.ready().then(() => {
// BackgroundGeolocation is highly configurable. See platform specific configuration options
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(config)
.then((location) => {
console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
// IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
// and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
// IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
BackgroundGeolocation.finish(); // FOR IOS ONLY
})
.catch((error) => {
console.log('BackgroundGeolocation error');
});
// 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();
}