you can tray inside your controller some thing like,
.controller(‘TestGeoCtrl’, function($scope, $cordovaBackgroundGeolocation) {
var bgGeo = window.plugins.backgroundGeoLocation;
var callbackFn = function(location) {
console.log(’[js] BackgroundGeoLocation callback: ’ + location.latitudue + ‘,’ + location.longitude);
// Do your HTTP request here to POST location to your server.
yourHTTP_POST_URL.call(this);
};
var failureFn = function(error) {
console.log('BackgroundGeoLocation error');
}
and then
bgGeo.configure(callbackFn, failureFn, {
url: ‘http://only.for.android.com/update_location.json’, // <-- only required for Android; ios allows javascript callbacks for your http
params: {
// HTTP POST params sent to your server when persisting locations.
auth_token: ‘user_secret_auth_token’,
foo: ‘bar’ // (ex : lat, lang, …)
},
headers: {
‘X-Foo’: ‘bar’
},
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
activityType: “AutomotiveNavigation”, // <-- iOS-only
debug: false // <-- enable this hear sounds for background-geolocation life-cycle.
});
// Turn ON the background-geolocation system.
bgGeo.start();
to stop the bgGeoloc, you can do some thing like :
$scope.stopBackgroundGeolocation = function () {
alert(‘location stoped’);
bgGeo.finish();
};
});
Ok. I allready read the readme form the plugin. I was just motivated negative by your topic about problems.
I will soon start to try to put this function in my app with crossed fingers.
@SamPa For me the same. Please post a codesample. I have frontendgeotracking working. Now I consider to implement backgroundtracking too.
I have a questions about this. After Reading the README I understand that backgroungptracking is not working in foreground. It start as soon as the app switches to background. So you have 2 different working ways of tracking.
How do you put these recordings together?
And what are the differences. Is backgroundtracking less accurate than foregroundtracking?
Is there a way to add properties to the json?