isaacadariku / flutter_native_badge

Wrapper for native badge APIs on iOS and macOS. It allows you to change the badge of your app icon, by setting the count, showing red dot, clearing the badge and getting the current badge count.
https://pub.dev/packages/flutter_native_badge
MIT License
6 stars 1 forks source link

Question on clearing of badges #5

Closed hagen00 closed 3 hours ago

hagen00 commented 3 hours ago

Hello, thank you for a great plugin.

We have internal app notifications, controlled by our own database. e.g a user may have "2 notifications for available gameboard plays".

Current behaviour: I set the badge count with FlutterNativeBadge.setBadgeCount(unreadNotificationCount);. This works. The user sees the badge count, opens the app by tapping on the app icon and the badge count CLEARS.

Desired behaviour: Is it possible, to only clear the badgecount if my database has unreadNotificationCount == 0? i.e the Flutter code controls when the badge clears and it no longer clears on tap?

hagen00 commented 3 hours ago

I'm doing this, which seems to work:


// in didChangeAppLifecycleState
if (state == AppLifecycleState.resumed) {
        // if we are resuming, let's get the notifications again, so that we set the badge on iOS
       appState.getUnreadNotifications();
}