Show current Badge Number
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.
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 Maybe it can be a Platform-specific functionality because some android devices didn't use numbers just alerts on top of the app icon.
I think that keeping state should be part of the app, not this plugin.
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)