Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Push notification badge count not being cleared #203

Closed
5 of 24 tasks
stib opened this issue Jun 25, 2024 · 1 comment
Closed
5 of 24 tasks

Bug: Push notification badge count not being cleared #203

stib opened this issue Jun 25, 2024 · 1 comment
Labels

Comments

@stib
Copy link

stib commented Jun 25, 2024

Plugin(s)

  • Android Foreground Service
  • Android Battery Optimization
  • App Update
  • Background Task
  • Badge
  • Bluetooth Low Energy
  • Cloudinary
  • Datetime Picker
  • File Compressor
  • File Opener
  • File Picker
  • Live Update
  • Managed Configurations
  • NFC
  • Photo Editor
  • Printer
  • Screen Orientation
  • Zip

Version

Badge 5.0.0

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

Things work just fine in iOS.

There are two issues in Android.

  1. The Badge clear does not clear the count coming from push notification. So if I have an App badge count of say 3 from push notifications that have come in, calling badge clear doesn't have any effect on that count. If I set badge count to 5 (through Badge.set) then App badge count will change to 5 and when that gets cleared through Badge.clear, the App badge count goes back to push notification count of 3. It seems like they are two different counts that the system maintains and the Badge.clear or the increase/decrease does not have any impact on the notification count and vice versa.
  2. (This is more of a P2 issue for me) When Badge.set is called at the beginning after App install, with a number say 10, that will not show up on the App badge. That will only show up if a notification is sent at which point instead of showing 1 for the push Notification count the App badge will show 10. After calling clear the App badge count, the badge will go back to 1 indicating the push notification count.

Sorry I don't have a minimal repro version in code for that as it is a complex application. If there aren't any obvious answers here then I will spend the time to try and create one.

Expected behavior

The count should go to 0 when Badge.clear is called independent of how the badge is set - through push notification or Badge.set.

(P2) The Badge count should increase the number on App icon independent of how that is set - through push notification or Badge.set

Reproduction

https://github.com/stib/not-there-yet

Steps to reproduce

  1. I am on Samsung Galaxy S22, Android version 13. Using @capawesome/capacitor-badge version 5.0.0
  2. Send push notification - App badge count goes to 1
  3. When App goes in background call Badge.clear
  4. Also set autoClear to true
  5. The push notification count does not change

Any badge count set through Badge.set will show up e.g. if set to 10 badge will show 10. When clear is called the count will go back to the push notification count.

Other information

Say Badge is set to 10 say through Badge.set and a new push notification is sent the Badge count remains at 10. Now when Badge.clear is called it will now show the count of push notifications that have come in (1 or 2 etc) - in the background some other counter seems to be keeping track of push notifications that is different from the Badge count set and cleared or increased/decreased by the Badge plugin.

In case it is relevant, the push notification data payload contains this JSON for the count. I am using "@capacitor/push-notifications": "^5.1.1" for push notificaitons.

        android: {
            priority: 'high',
            notification: {
                notificationCount: badge,
            },
        },

Capacitor doctor

Latest Dependencies:

@capacitor/cli: 6.1.0
@capacitor/core: 6.1.0
@capacitor/android: 6.1.0
@capacitor/ios: 6.1.0

Installed Dependencies:

@capacitor/core: 5.7.0
@capacitor/android: 5.7.0
@capacitor/ios: 5.7.0
@capacitor/cli: 5.7.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@stib stib added bug/fix Something isn't working needs: triage labels Jun 25, 2024
@robingenz
Copy link
Member

Thank you for your request. Your problems seem to be related to ShortcutBadger, the underlying library. You should therefore create an issue in the ShortcutBadger repository. The plugin itself is very simple and has no impact on the behavior you mentioned. I'm therefore closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants