Giter VIP home page Giter VIP logo

Comments (5)

christocracy avatar christocracy commented on June 6, 2024

In the API docs, of course

from cordova-background-geolocation-sampleapp.

Bwade avatar Bwade commented on June 6, 2024

Of course the API docs! Who would think to look there!

I do see the following in the Settings Controller:

  $scope.centerOnMe = function () {
    if (!$scope.map) {
      return;
    }

    BackgroundGeolocationService.getCurrentPosition(function(location, taskId) {
      $scope.map.setCenter(new google.maps.LatLng(location.coords.latitude, location.coords.longitude));
      $scope.setCurrentLocationMarker(location);
      BackgroundGeolocationService.finish(taskId);
    }, function(error) {
      console.error("- getCurrentPostion failed: ", error);
    }, {
      maximumAge: 0
    });
  };

When I modify the function like so:

$scope.centerOnMe = function () {
    if (!$scope.map) {
      return;
    }

    BackgroundGeolocationService.getCurrentPosition(function(location, taskId) {
      $scope.map.setCenter(new google.maps.LatLng(location.coords.latitude, location.coords.longitude));
      $scope.setCurrentLocationMarker(location);
      var device = window.localStorage.getItem('device');
      BackgroundGeolocationService.finish(taskId);
    }, function(error) {
      console.error("- getCurrentPostion failed: ", error);
    }, {
      maximumAge: 0,
      extra: {
        'device': device,
        'foo': 'bar' 
      }
    });
  };

I see the following in my Console

[js] onMotionChange:  false {"is_moving":false,"timestamp":"2015-11-17T20:02:22.043Z","uuid":"e9e4d0ef-469a-4bfb-b513-00e2c9759aec","coords":{"longitude":-90.3353283,"latitude":38.6489996,"accuracy":30,"speed":0,"heading":0,"altitude":0},"activity":{"type":"still","confidence":100},"battery":{"is_charging":true,"level":0.38999998569488525},"extras":{}} 

As you can see extra is empty.

is there a way to test what exactly is being sent to the server?

from cordova-background-geolocation-sampleapp.

christocracy avatar christocracy commented on June 6, 2024
  1. You're looking for your extras in the onMotionChange handler. They won't be there. The extras are only posted in the single location retrieved by getCurrentPosition.
  2. The name is extras (plural) -- not extra (singular). extras
  3. However, I don't think the extras are echoed back to your Javascript callback. You can be sure that if you provide extras to getCurrentPosition, they are most certainly posted to your server.

from cordova-background-geolocation-sampleapp.

christocracy avatar christocracy commented on June 6, 2024

And btw, if you're looking to POST Device info to your server, since this information is basically CONSTANT data, you'd be better off adding that to the plugin's #params config.

bgGeo.configure(success, fail, {
  .
  .
  .
  params: {
    device: window.localStorage.getItem('device')
  }
});

I do this in the SampleApp here

Anything added to #params is appended to each HTTP request.

from cordova-background-geolocation-sampleapp.

Bwade avatar Bwade commented on June 6, 2024

Thanks for all the help!

from cordova-background-geolocation-sampleapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.