capacitor-community / background-geolocation

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

Can not turn off background watch #65

Closed emil-alexandrescu closed 2 years ago

emil-alexandrescu commented 2 years ago

Describe the bug The background watch for location is turned on OS level. It seems like running removeWatcher won't turn it off.

To Reproduce Steps to reproduce the behavior:

Expected behavior

Screenshots 1

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

diachedelic commented 2 years ago

The addWatcher function no longer returns a watcher ID, it returns a Promise which resolves to a watcher ID. Check you are not passing a Promise to removeWatcher.

emil-alexandrescu commented 2 years ago

The addWatcher function no longer returns a watcher ID, it returns a Promise which resolves to a watcher ID. Check you are not passing a Promise to removeWatcher.

We are already using proper watch ID and I can see it in logs, but it didn't help.

diachedelic commented 2 years ago

Can you please provide some more information, for example the device you are using, it's operating system, and the code which uses this plugin?

wwwizzarrdry commented 2 years ago

It doesn't stop the watcher on Android either. The only way to stop the watcher is to close the app completely.

Edit: I forgot I have a scenario where multiple watchers could be created. I resolved my issue by adding the watcher_id's to an array and was able to pull them from there and kill off the desired watcher.

emil-alexandrescu commented 2 years ago

@wwwizzarrdry thanks for your reply. We are using only one watcher, but the watcher times out after certain amount of time as well when the app is in background. Is it desired behavior?

wwwizzarrdry commented 2 years ago

I haven't had an issue on my Pixel 2 regarding the service dying in the background. Longest running process, so far, has been an 1hr:15min and everything worked fine - no disconnects in the logs.

diachedelic commented 2 years ago

@emil-alexandrescu Please contribute your specifics to https://github.com/capacitor-community/background-geolocation/issues/69.