postTemplate is empty when it arrives to server
See original GitHub issueYour Environment
- Plugin version: 3.0.0-alpha.47
- Platform: Android
- OS version: 8.1.0
- Device manufacturer and model: Mi A1
- Running in Simulator: No
- Cordova version (
cordova -v
): 8.1.2 (cordova-lib@8.1.1) - Cordova platform version (
cordova platform ls
): android 7.1.2 - Plugin configuration options:
let header = { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept-Language': 'es', 'Authorization': 'Bearer ' + token, 'User-Agent': this.userAgent }
BackgroundGeolocation.configure({
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
desiredAccuracy: BackgroundGeolocation.MEDIUM_ACCURACY,
stationaryRadius: 30,
distanceFilter: 20,
interval: 30000, //180000
fastestInterval: 20000, //120000,
activitiesInterval: 10000,//20000,
stopOnTerminate: false,
startOnBoot: true,
startForeground: true,
pauseLocationUpdates: false,
maxLocations: 20,
stopOnStillActivity: false,
notificationTitle: "SmartLogin Mobile",
notificationText: "Activado en segundo plano",
url: url + paraID,
syncUrl: url + paraID,
httpHeaders: header,
postTemplate: {
lat: '@latitude',
lon: '@longitude'
},
});
BackgroundGeolocation.checkStatus(res => {
if (!res.isRunning) {
BackgroundGeolocation.start();
}
})
Context
I’m working in an Ionic app which needs to register background geolocation using the plugin which works great. I have tried to use my custom http request with an interval to send the data when the app is in background (is working perfectly in foreground) but Android kills the process after 5 minutes approx.
So I have tried using the url, headers and postTemplate parameters of the configuration instead of my custom http code but postTemplate seems to be empty when it arrives to my server however the request is being successful.
Headers and url are working as expected so it has to be a problem with the postTemplate var.
Expected Behavior
postTemplate not being empty.
Actual Behavior
postTemplate var is empty so I can’t register the geolocation in my server
Possible Fix
Maybe some parse bug, I don’t really know.
Steps to Reproduce
Context
Debug logs
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
for most servers it’s important to send correct content-type. The plugin is already sending corrent-type. If you override it, your server will not be able to parse the content and that’s why you get empty response.
Already solved! It was the problem with the headers as you say. We didn’t need to send any ‘Content-type’ headers instead of that it’s necessary to parse the object in the backend.
Really grateful for your help 😃