Closed dmitry-stepanenko closed 4 years ago
BackgroundGeolocation.destroyLocations()
The plugin has queued records encoded with previous or default template. It keeps attempting to upload those old records and your server keeps returning non-200 response. The plugin is going to keep trying until you either:
destroyLocations
200
I've done what you said and now the payload looks like this:
{
"location": {
"Lat": 37.2600333,
"Lng": -122.1017383
}
}
Is it possible to make Lat
\ Lng
properties in the root of the object?
The answer is in the api docs. Search for “rootProperty”
you can use this property ( httpRootProperty: '.' ) to get data in root. thanks
yes, I've already used this and it did the trick. thanks
How can i check the format the payload is beeing sent in android studio ?
You can’t. Make sure the plugin database doesn’t have old locations rendered with default template via #destroyLocations
i'm doing : BackgroundGeolocation.start(); BackgroundGeolocation.destroyLocations();
Should this be enough ?
You should not always be using #destroyLocations each time the app starts.
These are the configs i'm using:
httpRootProperty: '.', url: appSettings.getString("API_URL") + ":" + appSettings.getString("API_PORT") + "/v1/user/location", locationTemplate: '{ "latitude":<%= latitude %>, "longitude":<%= longitude %> }', autoSync: true, autoSyncThreshold: 5, batchSync: true, maxBatchSize: 50, method: 'POST', headers: { "content-type" : "application/json", "Authorization": widget.currentUser.token, }, locationsOrderDirection: "DESC", maxDaysToPersist: 14,
I would expect the payload to be : { "latitude" : 12.546, "longitude": 64654.323} would it be a correct assumption ?
Yes
@ptv1p3r How can i check the format the payload is beeing sent in android studio ?
You can see it in android studio's profiler in network section
You can see it in android studio's profiler in network section
Oops, sorry. Misunderstood your post. You can? Show me a screenshot of that.
You can see it in android studio's profiler in network section
Oops, sorry. Misunderstood your post. You can? Show me a screenshot of that.
same.. how can i see it? it would solve a lot of problems here eheh...
Just found out how :-) TY
Oh, that’s neat!
And i just found out one the problems, it's that not all keys are always present, for instance event ... i thought from the documentation that it would always be present, but it could be empty, that's not the case, if it's empty, the key does not exist...
Correct. No point inflating the data with an empty-string.
Yes, but it's not explicit in the documentation and it should.. now the question rises, what other keys have the same behavior ?
@ptv1p3r How can i check the format the payload is beeing sent in android studio ?
You can see it in android studio's profiler in network section
Thank You !!!!!! You are a life saver !!!!
See Wiki Location Data Schema
See Wiki Location Data Schema
So those keys will always be present, and all others may or may not be present depending on content ? is that correct ?
yes
Your Environment
#ready
:Please note, that actual endpoint and authorization are being removed from an example. When tested, I used real endpoint.
Expected Behavior
Location template should be applied within a configuration.
Actual Behavior
I am providing location template in a configuration as follows:
locationTemplate: '{"Lat": <%= latitude %>, "Lng": <%= longitude %>}',
Using android profilier I've checked the payload that is being sent and it's as follows:
Steps to Reproduce
Created a blank ionic capacitor application to reproduce. Please, take a look https://github.com/cuddlemeister/bug-reproduction-cordova-background-geolocation-lt