flutter_app_badger icon indicating copy to clipboard operation
flutter_app_badger copied to clipboard

Show current Badge Number

Open pelli23 opened this issue 6 years ago • 4 comments

It would be great that the plugin could get the current badge number. Same method for set the current number, but fot get the number.

Thanks.

pelli23 avatar Dec 29 '19 19:12 pelli23

Hello,

Thanks @pelli23, that's a nice idea!

However I can not develop a correct implementation:

  • it will work perfectly fine on iOS
  • on Android, there is no way to extract this information from the launcher

I have to think about how to provide the best implementation possible on Android.

g123k avatar Dec 29 '19 19:12 g123k

@g123k Maybe it can be a Platform-specific functionality because some android devices didn't use numbers just alerts on top of the app icon.

LutfiGarzon avatar Sep 17 '21 05:09 LutfiGarzon

I think that keeping state should be part of the app, not this plugin.

ariejan avatar Apr 08 '22 08:04 ariejan

A bit late to comment maybe, but I also face this issue with needing the current badge number in order o be able to increase the badge number instead of just setting it. iOS only would be better than no support at all. When the state can be kept in the app this is no issue of course but in my case I use the counter for background notifications and call it in the FIrebaseMessaging handler, like so:

@pragma('vm:entry-point') Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); FlutterAppBadger.updateBadgeCount(1); }

According to Google's documentation:

Since the handler runs in its own isolate outside your applications context, it is not possible to update application state or execute any UI impacting logic.

So, afaiu, the only way to get the badge to count up for each incoming notification would be if FlutterAppBadger itself would keep the count state. (But I'm new to the party so if I miss something obvious bear with me)

oander11 avatar Sep 09 '23 07:09 oander11