capacitor-community / background-geolocation

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

Custom setInterval and minUpdateInterval #90

Closed CoooWeee closed 1 year ago

CoooWeee commented 1 year ago

Describe the bug Previously, I used the google location API and got really "good" (fast update rate & okay precision) locations even if without GPS coverage. Now, I am using this plugin with android and it seems as indoors or next to high-rise buildings I do not get often a location, and if the precision is not as good. If I open my old APP or google maps the location immediately improves (precision & update rate).

It seems as if it does not do well with the fused location.

To Reproduce Steps to reproduce the behavior: 1.

    self.gpsWatchId = await BackgroundGeolocation.addWatcher(
      {
        requestPermissions: true,
        stale: true,
        distanceFilter: 0,
      },
  1. be somewhere inside where you do not have good GPS coverage but your google maps works.

Version "@capacitor-community/background-geolocation": "^1.2.7",

Smartphone (please complete the following information): pixel 5

Additional context Add any other context about the problem here.

diachedelic commented 1 year ago

What should we use instead of the fused location provider?

CoooWeee commented 1 year ago

I think the issue is that the intervals are not setable.

setWaitForAccurateLocation is by default true but it seems only to work if the intervals are set accordingly.

I changed the code to:


LocationRequest locationRequest = new LocationRequest.Builder(LocationRequest.PRIORITY_HIGH_ACCURACY, 1000) 
                     .setMinUpdateIntervalMillis(500) 
                     .setMinUpdateDistanceMeters(distanceFilter) 
                     .setMaxUpdateDelayMillis(1000) // default 
                     .build();```
diachedelic commented 1 year ago

Are you saying that setting setWaitForAccurateLocation to false is not enough?

CoooWeee commented 1 year ago

Are you saying that setting setWaitForAccurateLocation to false is not enough?

For my use case it has to be true. I want as high accuracy as I can get but want to fall back on non-gps if not available.

I changed my previous comment to reflect what I'm using at the moment. That fixed it for me (fused location).

diachedelic commented 1 year ago

Are you saying that non-GPS locations are accurate enough for your purposes? What kind of accuracy readings do you get from them?

CoooWeee commented 1 year ago

Are you saying that non-GPS locations are accurate enough for your purposes? What kind of accuracy readings do you get from them?

No, I'm saying they are not accurate enough but better than nothing.

diachedelic commented 1 year ago

But if you set setWaitForAccurateLocation to false, then the locations are too inaccurate for you?

diachedelic commented 1 year ago

Like, that is worse than nothing?

diachedelic commented 1 year ago

I noticed that in your watcher configuration, you set stale: true which implies that you want locations as soon as possible, regardless of their accuracy. I am thinking that the plugin should set setWaitForAccurateLocation to false when stale is true.

But with regards to your issue, are you saying that by adding

                     .setMinUpdateIntervalMillis(500)
                     .setMaxUpdateDelayMillis(1000)

the initial locations arrive faster?

CoooWeee commented 1 year ago

But if you set setWaitForAccurateLocation to false, then the locations are too inaccurate for you?

Why would I set it to false? If I get a more accurate GPS position, I wanna wait for it and use it instead of the non-gps.

I think setWaitForAccurateLocation = false is only for cases where you don't care much about accuracy but more about having a location as fast as possible.

diachedelic commented 1 year ago

Sorry, I'm struggling to understand exactly what your priorities are. Please explain your position on the following: