OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
612 stars 212 forks source link

[Feedback]: Add the method to set the app badge count manually. #601

Open vernalclareai opened 1 year ago

vernalclareai commented 1 year ago

What's on your mind?

I want to add one function to set the app badge count manually on foreground state.

OneSignal.shared.clearOneSignalNotifications();

This method worked well. Checked this method is putting the app badge count as 0. If possible, please provide the method also to set the custom count for app badge. So when the app is on foreground, I can set the app badge count according to the unread logic. Thanks.

Code of Conduct

jkasten2 commented 1 year ago

@vernalclareai Thanks for the suggestion, however Android only allows setting a badge number in conjunction with showing a notification. See Android's Modify a Notification Badge for the details on this limitation.

Before Android 8 (Oreo) introduced notification badges (also known as notification dots) it was common for device manufactures to add their own badge counts. However I believe most of them (if not all) have dropped theirs in-favor of Android official supported noted above. Let us know however if this is not the case.

vernalclareai commented 1 year ago

okay, I will provide more details with the video recording. @jkasten2

vernalclareai commented 1 year ago

Hi, @jkasten2 Just sharing more details. iOS version is working well, but Android is always increasing the app badge count from 0 although set the count using the FlutterAppBadger.updateBadgeCount(unreadCount)

iOS Recording :

https://user-images.githubusercontent.com/61595318/209926477-134833a0-a191-46b2-a88b-d80606705c2a.mp4

Android Recording:

https://user-images.githubusercontent.com/61595318/209926617-9978968f-7ce9-4409-86c6-85862036a825.mp4

Can you check the updateBadgeCount func and fix? or suggest to use another func for this case? Thanks.

chiennv23 commented 1 year ago

@vernalclareai Can you show me some code counting badge on ios when run background, my ios show notifications but badge not update. Thanks

vernalclareai commented 1 year ago

Hi, @chiennv23 Badge count will be increased automatically when receiving the push notification.