transistorsoft / cordova-background-geolocation-SampleApp

Cordova Background Geolocation Sample Application
https://www.transistorsoft.com/shop/products/cordova-background-geolocation
MIT License
122 stars 78 forks source link

no request params? #58

Closed datadreamersllc closed 8 years ago

datadreamersllc commented 8 years ago

I have the paid version and built the sampleapp with it. Everything seems to work fine in the app itself -- I configured the url to like http://mysite.com/u.asp and it makes POST requests to that url, but there are no request parameters being sent? I would expect something like lat/lon request parameters to be included in the requests.

I then tried editing configureBackgroundGeolocation to include: config.params = {"test":"55"}; but looking at the server logs there is no "test" parameter being sent.

This is on a Sprint Galaxy Note 3

christocracy commented 8 years ago

are you using PHP?

datadreamersllc commented 8 years ago

Its a tomcat java servlet. I have a debugging filter that logs each request and its parameters/headers to a file. If there were params in the request, it would definitely show them.

christocracy commented 8 years ago

Here's what I see from my Node server

---------------------------------------------------------------------
- POST /locations
 {
  "location": {
    "coords": {
      "speed": -1,
      "longitude": -73.61679625228976,
      "latitude": 45.51926426842272,
      "accuracy": 65,
      "heading": -1,
      "altitude": 76.11406707763672,
      "altitudeAccuracy": 10
    },
    "is_heartbeat": false,
    "is_moving": false,
    "event": "motionchange",
    "odometer": 0,
    "uuid": "D3371D99-49D1-4D57-8EC0-E143BEA65F61",
    "activity": {
      "type": "still",
      "confidence": 100
    },
    "battery": {
      "level": 1,
      "is_charging": true
    },
    "timestamp": "2016-10-05T17:04:50.443Z"
  },
  "device": {
    "serial": "unknown",
    "manufacturer": "Apple",
    "available": true,
    "platform": "iOS",
    "cordova": "4.2.1",
    "uuid": "48DB84D9-89CC-4A95-AC36-797B3B9FBBF2",
    "model": "iPhone8,1",
    "version": "10.0.2",
    "isVirtual": false
  }
}
datadreamersllc commented 8 years ago

do you have a url i can enter to see if you get anything?

christocracy commented 8 years ago

The plugin is most certainly posting the data. The plugin places the data in the JSON body of the request. If you're expecting the request to look like a form-post, you won't find anything.

christocracy commented 8 years ago

Are you watching $ adb logcat while the plugin is posting requests?

datadreamersllc commented 8 years ago

But what about the config.params = {"test":"55"}? Shouldn't that add a standard request paramater?

christocracy commented 8 years ago

No. The #params are merged with the JSON-body of the request.

bgGeo.configure({
  params: {  
    device:  {
      "serial": "unknown",
      "manufacturer": "Apple",
      "available": true,
      "platform": "iOS",
      "cordova": "4.2.1",
      "uuid": "48DB84D9-89CC-4A95-AC36-797B3B9FBBF2",
      "model": "iPhone8,1",
      "version": "10.0.2",
      "isVirtual": false
    }
  }
});
- POST /locations
 {
  "location": {
    "coords": {
      "speed": -1,
      "longitude": -73.61682591956591,
      "latitude": 45.51925652956984,
      "accuracy": 65,
      "heading": -1,
      "altitude": 76.09185791015625,
      "altitudeAccuracy": 10
    },
    "is_heartbeat": false,
    "is_moving": false,
    "event": "motionchange",
    "odometer": 0,
    "uuid": "FF2CB1D1-0526-4DAE-B173-2ABB141F14D3",
    "activity": {
      "type": "still",
      "confidence": 100
    },
    "battery": {
      "level": 1,
      "is_charging": true
    },
    "timestamp": "2016-10-05T17:17:29.251Z"
  },
  "device": {   // <---------- params are merged to the JSON-body.
    "serial": "unknown",
    "manufacturer": "Apple",
    "available": true,
    "platform": "iOS",
    "cordova": "4.2.1",
    "uuid": "48DB84D9-89CC-4A95-AC36-797B3B9FBBF2",
    "model": "iPhone8,1",
    "version": "10.0.2",
    "isVirtual": false
  }
}
datadreamersllc commented 8 years ago

You are right -- I was looking for the data to be associated with normal form post parameter, but serializing the request body the data is there.

christocracy commented 8 years ago

The data is always there :)