leolin310148 / ShortcutBadger

An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.
Other
7.35k stars 1.34k forks source link

App badge odd behaviour #359

Open bockc opened 3 years ago

bockc commented 3 years ago

I noticed that there's 2 behaviours for push notifications on Android :

For instance, WhatsApp counts the number of conversations containing unread messages and sets the badge accordingly. Whether you start the app and/or dismiss all notifications, the badge stays here and only updates when you read one of those conversations or receive a new message in another one. Slack on the other hand works by counting the number of notifications in the system tray.

Another strange thing I noticed is that you can set a badge number like 42, but it won't appear since this library seems to only allow the notifications count mode. However, if you receive any notification, 42 will be set as the app's badge (not 43...). Right now, you'd expect that any new notification would bump the badge from 42 to 43 and so on since it's counting the notifications in my system tray, right ? Unfortunately it doesn't, you'd have to manually set the badge every time if you already did it once for your Android app I guess.

When my app receives a push notification when in background or killed state, I update my app badge from Firebase's backgroundMessageHandler. Anyway, I noticed the badge stays displayed and doesn't change when I dismiss a notification, but if I dismiss all of my notifications, the badge disappears...

Also, it's worth noting that I'm using this library wrapped in react-native-push-notification.

Am I doing something wrong here ? My ideal goal would be having the same behaviour than iOS, but unfortunately right now I'm only able to have something in between iOS and Android. I'd like either my badge to reflect the actual notifications count or a badge that persists even when there's no notification in the system tray, because right now I am only able to offer this weird and confusing experience to our users.

Thanks !

magamal commented 3 years ago

Any updates about this issue ??

theneekz commented 2 years ago

This is an Android launcher specific problem. You can set the icon number manually like you do for iOS but the device's settings will take precedence, what ever they are. My Samsung S9 running Android 10 has this important message in Settings -> Notifications -> App Icon Badged (it looks like a toggle but it will link to a page with more options):

"Show badges on apps that have notifications. Clear the notifications to remove the badges"

Sadly this is a feature and not a bug with some Android devices. I do think this package can be used in tandem with the Android device's default behavior.