capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
180 stars 56 forks source link

setting distance filter when a gps already run #41

Closed gine closed 2 years ago

gine commented 2 years ago

Can be really useful a function to set the distance filter. I need to set it using the speed parameter:

More speed = mode distance filter less speed = less distance filter

You can do it in 2 ways:

1) permitting to pass to distance filter a function that must return a number 2) an external function setDistanceFilter to set the parameter when user need to do it

diachedelic commented 2 years ago

It looks like it may be possible to set the CLLocationManager#distanceFilter property on the fly on iOS, but not on Android. This is because the setSmallestDisplacement method is on the LocationRequest, which is no longer mutable once submitted.

I would recommend you simply remove and add watchers in response to changes in speed. I would be surprised if this strategy caused any negative impact on accuracy.

diachedelic commented 2 years ago
  1. permitting to pass to distance filter a function that must return a number

Please also note that as Capacitor plugin methods can only take listener functions as parameters, this would not be possible.