Location events return a limited result compared to the documentation
See original GitHub issueYour Environment
- Plugin version: 3.0.0-alpha.24
- Platform: iOS, Android
Context
The location object passed to the callback for the location event (BackgroundGeolocation.on(‘location’, callback)) does not contain the id, recordedAt, provider, locationProvider, or radius fields.
Expected Behavior
From the documentation, the location passed to the event should contain all of the fields stated in the documentation: https://github.com/mauron85/cordova-plugin-background-geolocation#location-event
Locations passed from getValidLocations() and getAllLocations() do contain all of the stated fields, it’s just the event handler instance that lacks them.
Actual Behavior
Location passed from .on(‘location’):
[Log] Position updated successfully (ion-dev.js, line 156)
{accuracy: 5, altitude: 0, altitudeAccuracy: -1, bearing: 3.6, heading: 3.6, latitude: 37.33051095, longitude: -122.02324266, speed: 6.24, time: 1524431657421.781}
A comparative value passed for a location from getValidLocations():
[Log] getValidLocations() (ion-dev.js, line 156)
Array (5)
0: { accuracy: 10, altitude: 0, bearing: 86.17, heading: 86.17, id: 1749, latitude: 37.33023256, locationProvider: 0, longitude: -122.02344987, recordedAt: 0, speed: 1.05, time 1524431646428.674 }
...
Possible Fix
Location.m and BackgroundLocation.java appear to contain the relevant code for this process.
Steps to Reproduce
- Compare the output of a location event to what is passed from getValidLocations.
Context
Considering that the returned Location is already not a valid Position object, I don’t understand the need for different data types to begin with. The full data set would be useful for analytics and tracking the accuracy of different providers.
I have a custom way of handling locations in my app that I don’t want to go through the sync and backgroundSync functionality. Without the id
being passed I cannot use the deleteLocation method to remove the location from the list of valid locations, I have to manually compare them using getValidLocations.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
just will add here, that in future plugin will be able to cover your use case better. I’m thinking about adding processing chains, where you’ll be able to put together simple units of work into the chain. Like onLocation -> filterLocation -> postLocation -> saveLocation -> … All from javascript.
The issue remains.
BackgroundGeolocationResponse
doesn’t haveprovider
, which is quite important.EDIT: I was confused with
@ionic-native/background-geolocation
’sBackgroundGeolocationResponse
, which was fixed in version 4.20 of the plugin