Android notification stays after calling removeWatcher
See original GitHub issueI start by calling addWatcher()
and then after some time I decide to remove it by calling removeWatcher()
. My understanding would be that the sticky notification would disappear when there is no active watcher. No watcher means no location tracking and that should be no notification, is that right?
I have a special option inside my app settings that allows users to switch background geolocation on/off. The idea was to remove the watcher when app is being backgrounded and then start it again when it’s foregrounded.
The sample approach and logic I tried is something like this. I’m using Capacitor’s App plugin to detect if the app was backgrounded or foregrounded.
App.addListener("appStateChange", state => {
if (!this.canUseBackgroundGps) {
if (state.isActive) {
BackgroundGeolocation.addWatcher(/* ... */);
} else {
BackgroundGeolocation.removeWatcher(/* ... */);
}
}
});
I only tested and observed this behaviour on Android. I’ll test if it behaves the same on iOS tomorrow.
Thanks for any heads up, Patrik
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
The problem was that I thought
addWatcher()
was returning the watcher ID as aPromise
. It works as expected in 0.3.8 anticipating a string instead.Thanks.
Any suggest