$cordovaBackgroundGeolocation sample

hi Ionics !
i’m looking for some $cordovaBackgroundGeolocation sample, with ionic.
i tray with some thing like, and got " dbg is undefined" :

.controller(‘TestMapCtrl’, function($scope, $cordovaBackgroundGeolocation) {

  //$ionicPlatform.ready(function() {
    var options = {
      params:{auth_token:'user_secret_auth_token',lat:'lat', lng:'lng'},
      desiredAccuracy: 10,
      stationaryRadius: 10,
      distanceFilter: 30,
      activityType: 'AutomotiveNavigation',
      debug: true,
      stopOnTerminate: false  //  enable this to clear background location settings when the app terminates

  // `configure` calls `start` internally
  $cordovaBackgroundGeolocation.configure(options).then(function (location) {
    alert('success location: ' + location);
  }, function (err) {
    alert('Unable to get location: ' + error);


  $scope.stopBackgroundGeolocation = function () {


any help?!

with best,

I have plans to change my inline-app getCurrentgeolocation into background.
Let me know if you get it running?

Did you installed the plugin?

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.

        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. 

to stop the bgGeoloc, you can do some thing like :
$scope.stopBackgroundGeolocation = function () {
alert(‘location stoped’);

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.

ok. it works fine right now.
i’m looking for a way to hide push notifications.
plz let me know if you have an idea.


Maybe iets better to start a new thread for hiding pushnotifiations.

BTW what do you mean by hiding pushnotifications

Can you show me some implementation of your code? I am not able to figure out how json is posted in the request body to the backend

@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?