I need to realize an app that store user journey (path) when he moves from A to B. Now, I know that ionicframework can use GPS, but what happen when my APP go to background ? Ho
I just finished writing a new cordova background geolocation plugin for ios and android, its free and simple! try it out:
https://github.com/pmwisdom/cordova-background-geolocation-services
Ionic Usage :
//Wait for cordova / ionic ready to use the plugin
ionic.Platform.ready(function(){
//Make sure to get at least one GPS coordinate in the foreground before starting background services
navigator.geolocation.getCurrentPosition();
//1. Get plugin
var bgLocationServices = window.plugins.backgroundLocationServices;
//2. Configure Plugin
bgLocationServices.configure({
desiredAccuracy: 20,
distanceFilter: 5,
notificationTitle: 'BG Plugin',
notificationText: 'Tracking',
debug: true,
interval: 9000,
fastestInterval: 5000
});
//3. Register a callback for location updates, this is where location objects will be sent in the background
bgLocationServices.registerForLocationUpdates(function(location) {
console.log("We got a BG Update" + JSON.stringify(location));
}, function(err) {
console.log("Error: Didn't get an update", err);
});
//4. Start the Background Tracker. When you enter the background tracking will start, and stop when you enter the foreground.
bgLocationServices.start();
///later, to stop
bgLocationServices.stop();
});
It's possible with a plugin you're referring as a $600+ premium plugin.
People usually forget that older versions are also available, including last viable Android/iOS version: https://github.com/christocracy/cordova-plugin-background-geolocation/tree/0.3.7
ionic plugin add cordova-plugin-background-geolocation@1.0.5
Currently, other distinct versions do not exist, everything else is just a fork of this original plugin.