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.

Android notification stays after calling removeWatcher

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
pdrhlikcommented, Feb 8, 2021

The notification certainly should disappear – are you absolutely sure that all watchers have been removed at that point? Do you retain the id from addWatcher for later use with removeWatcher?

The problem was that I thought addWatcher() was returning the watcher ID as a Promise. It works as expected in 0.3.8 anticipating a string instead.

Thanks.

0reactions
matudelatowercommented, Apr 7, 2022

Any suggest

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android notification stays open when launching app
If I remove the call to startActivity, the notification will close. I'm assuming that your Activity is just reposting the Notification .
Read more >
Control notifications on Android - Google Help
Open your phone's Settings app. · Tap Apps & notifications and then Notifications. · Under “Recently Sent,” tap an app. · Tap a...
Read more >
Notifications Overview | Android Developers
The heads-up notification appears the moment your app issues the notification and it disappears after a moment, but remains visible in the notification...
Read more >
Troubleshooting Duo Push notification issues on Android ...
When you first install and start using Duo Mobile on Android versions 13 and later, Android may ask if you want to receive...
Read more >
Bug with dismissing notification in Android.
When receiving call notification pop-up on Android appears with Accept/decline ... It is stuck there indefinitely until I restart phone.
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