christocracy / cordova-plugin-background-geolocation

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection
http://transistorsoft.github.io/cordova-background-geolocation
492 stars 744 forks source link

Android POSTing previous locations with new location #227

Closed doorty closed 9 years ago

doorty commented 9 years ago

I'm testing on a Samsung Galaxy S5 in Genymotion. Whenever I set the GPS to a new location (far enough outside the stationary radius), I get multiple HTTP POSTs with all the previous locations.

1) 1st location change: 1 HTTP POST 2) 2nd location change: 2 HTTP POST 3) 3rd location change: 3 HTTP POST

Here are the results after 3 location changes:

{
      "location": {
        "bearing": "0.0",
        "longitude": "-18.508528333333334",
        "recorded_at": "2015-08-06T21:23Z",
        "latitude": "65.99044333333333",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "0.0"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 1
    },
    {
      "location": {
        "bearing": "0.0",
        "longitude": "-18.508528333333334",
        "recorded_at": "2015-08-06T21:23Z",
        "latitude": "65.99044333333333",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "0.0"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 2
    },
    {
      "location": {
        "bearing": "0.0",
        "longitude": "-18.511039999999998",
        "recorded_at": "2015-08-06T21:24Z",
        "latitude": "65.99184833333334",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "0.0"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 3
    },
    {
      "location": {
        "bearing": "0.0",
        "longitude": "-18.508528333333334",
        "recorded_at": "2015-08-06T21:23Z",
        "latitude": "65.99044333333333",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "0.0"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 4
    },
    {
      "location": {
        "bearing": "0.0",
        "longitude": "-18.511039999999998",
        "recorded_at": "2015-08-06T21:24Z",
        "latitude": "65.99184833333334",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "0.0"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 5
    },
    {
      "location": {
        "bearing": "0.0",
        "longitude": "-18.538741666666667",
        "recorded_at": "2015-08-06T21:25Z",
        "latitude": "66.00503666666667",
        "speed": "0.0",
        "accuracy": "1.0",
        "altitude": "262.929626"
      },
      "test": "test",
      "auth_token": "user_secret_auth_token",
      "id": 6
    }
christocracy commented 9 years ago

Is your server receiving and responding with http 200 to those POST?

Any response other than 200 will not remove the location from SQLite. The plugin will continue attempting to sync all recorded locations.

Once 200 is received, location is deleted from SQLite.

On Thursday, August 6, 2015, Brent Daugherty notifications@github.com wrote:

I'm testing on a Samsung Galaxy S5 in Genymotion. Whenever I set the GPS to a new location (far enough outside the stationary radius), I get multiple HTTP POSTs with all the previous locations.

1) 1st location change: 1 HTTP POST 2) 2nd location change: 2 HTTP POST 3) 3rd location change: 3 HTTP POST

Here are the results after 3 location changes:

{ "location": { "bearing": "0.0", "longitude": "-18.508528333333334", "recorded_at": "2015-08-06T21:23Z", "latitude": "65.99044333333333", "speed": "0.0", "accuracy": "1.0", "altitude": "0.0" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 1 }, { "location": { "bearing": "0.0", "longitude": "-18.508528333333334", "recorded_at": "2015-08-06T21:23Z", "latitude": "65.99044333333333", "speed": "0.0", "accuracy": "1.0", "altitude": "0.0" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 2 }, { "location": { "bearing": "0.0", "longitude": "-18.511039999999998", "recorded_at": "2015-08-06T21:24Z", "latitude": "65.99184833333334", "speed": "0.0", "accuracy": "1.0", "altitude": "0.0" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 3 }, { "location": { "bearing": "0.0", "longitude": "-18.508528333333334", "recorded_at": "2015-08-06T21:23Z", "latitude": "65.99044333333333", "speed": "0.0", "accuracy": "1.0", "altitude": "0.0" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 4 }, { "location": { "bearing": "0.0", "longitude": "-18.511039999999998", "recorded_at": "2015-08-06T21:24Z", "latitude": "65.99184833333334", "speed": "0.0", "accuracy": "1.0", "altitude": "0.0" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 5 }, { "location": { "bearing": "0.0", "longitude": "-18.538741666666667", "recorded_at": "2015-08-06T21:25Z", "latitude": "66.00503666666667", "speed": "0.0", "accuracy": "1.0", "altitude": "262.929626" }, "test": "test", "auth_token": "user_secret_auth_token", "id": 6 }

— Reply to this email directly or view it on GitHub https://github.com/christocracy/cordova-plugin-background-geolocation/issues/227 .

Snet form Gmail Mobile

doorty commented 9 years ago

Oh, it's returning 201.

christocracy commented 9 years ago

The plugin should have been written to accept a 200-ish response but it's clearly not.