react-native-background-geolocation
react-native-background-geolocation copied to clipboard
Provide extra field per location
Not a bug report so the template didn't seem relevant, I hope that's OK.
I was wondering if there's a way to set the extra field for every location. The location event seems to get the location data but a there's no location returned I guess I can't change the location in there.
My use case is that I need to do a lookup using the latitude and longitude and they include the ID of the nearest linestring in the API call to the server, sending the location. If I can do that and include it in the location data structure then it would be stored locally when offline and sent to the server when online. The reason for this is to find which road I'm on and tag each API call with that road. How I actually find which road I'm on, locally and offline, if another problem and out of the scope of this library.
was wondering if there's a way to set the extra field for every location
No. It's impossible.
Anyway, reverse geolocation is a task best done on your server, since it requires an extra http request and http requests consume energy.
Thanks for the quick reply.
My use case is for an offline first app so I guess I'm looking for a workaround or another library to do this. Is there a way to intercept the HTTP calls perhaps? Or modify the internal SQLite DB before locations are sent?
Or modify the internal SQLite DB before locations are sent
Yes, but not with JavaScript. It can only be done by implementing an undocumented method in pure Obj-c (iOS)/ Java (Android) then implementing your reverse-geocoding using pure native code.
Thanks for the insights Chris, your library is amazing so I very much want to use it for my app. I guess I have a difficult problem to solve :)
If I can get a number from an async JS call, given the latitude and longitude, not an API request or anything like that, can you think of a way I can add that to my API call when the library goes back online?
Perhaps I need to remove the URL so requests don't go at all, then control offline handling myself and pre-process each location when the API requests are made. Seems complicated but if there's no way to influence what's going on interally then perhaps that's what I need to do.
Anyway, thanks again for the responses. It's late here so I'll sleep on it.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.