question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Location events return a limited result compared to the documentation

See original GitHub issue

Your 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

  1. 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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mauron85commented, Apr 23, 2018

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.

0reactions
Alain1405commented, Jan 31, 2019

The issue remains. BackgroundGeolocationResponse doesn’t have provider, which is quite important.

EDIT: I was confused with @ionic-native/background-geolocation’s BackgroundGeolocationResponse, which was fixed in version 4.20 of the plugin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use query parameters to customize responses - Microsoft Graph
Microsoft Graph provides optional query parameters that you can use to specify and control the amount of data returned in a response.
Read more >
Events API - MoodleDocs
Events are atomic pieces of information describing something that happened in Moodle. Events are primarily the result of user actions, ...
Read more >
Places Library | Maps JavaScript API - Google Developers
For more information, see the autocomplete documentation. ... Nearby Search returns a list of nearby places based on a user's location.
Read more >
NRQL syntax, clauses, and functions | New Relic Documentation
SHOW EVENT TYPES will return a list of all the data types present in your account for a specific time range. It is...
Read more >
Webhook events and payloads - GitHub Docs
Learn about when each webhook event occurs and what the payload contains. ... Pushes to a branch in a forked repository are not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found