Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

We can not reset the app badge in some android devices #71

Open
gujingc opened this issue Feb 14, 2023 · 2 comments
Open

We can not reset the app badge in some android devices #71

gujingc opened this issue Feb 14, 2023 · 2 comments

Comments

@gujingc
Copy link

gujingc commented Feb 14, 2023

We are completing a chat app in flutter using this plugin.

Our chat app runs on Firestore.

When there are unread messages, we would like the app to display a badge reminding our users there are messages to check.

Our users would like to see the badge reset to zero and the badge disappears after the messages are all checked.

The first part showing the badge when there are unread messages work well. However, after checking the message, the badge does not reset.

This is our screenplay.

Screenplay - Badge does not reset.

We tried this code:
@override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: log("MyApp: AppLifecycaeState.resumed"); FlutterAppBadger.removeBadge(); break; case AppLifecycleState.paused: updateMyActiveStatus(false); log("MyApp: AppLifecycleState.paused"); break; case AppLifecycleState.inactive: log("MyApp: AppLifecycleState.inactive"); break; case AppLifecycleState.detached: log("MyApp: AppLifecycleState.detached"); break; default: break; }
Code in pastebin
We also tried this code:

@override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: log("MyApp: AppLifecycaeState.resumed"); break; case AppLifecycleState.paused: updateMyActiveStatus(false); log("MyApp: AppLifecycleState.paused"); FlutterAppBadger.removeBadge(); break; case AppLifecycleState.inactive: log("MyApp: AppLifecycleState.inactive"); break; case AppLifecycleState.detached: l log("MyApp: AppLifecycleState.detached"); break; default: break; }
or Code in Pastebin

Neither works. Is this our code or an issue with the plugin?

Thanks for your insight.

@ShuheiSuzuki-07
Copy link

Android does not offer the same badge display functionality at the OS level as iOS. They are provided at the API level by the manufacturer of the device or launcher application (e.g. MicrosoftLauncher). Basically, Android should not support Badge display and should conform to the specifications of the OS, launcher app, and device.

@ShuheiSuzuki-07
Copy link

Incidentally, on Android, you can remove the badge display by writing the following code on the native side at startup and calling it from Flutter.
However, this will also remove the notification from the Notification Center.

val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancelAll()

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

No branches or pull requests

2 participants