问题
I want to set the count of the badge per hand in react-native with firebase.
firebase.notifications.setBadge(number)
how to get the number?
回答1:
you can use firebase.notifications.getBadge(), like described in the Docs: https://rnfirebase.io/docs/v5.x.x/notifications/reference/Notifications#getBadge
But I wonder, it doesn't seem to be the total of received messages. I think the Idea behind this is, that you add (and increment for each message) an setBadge to your onNotifications.
But the question at all (I think thats also what the Thread-Opener means), how do I get the total number of received messages per app. It should be possible, because it's still used in Android:
回答2:
RN-Firebase >= v6 The above answer was for RN-Firebase v5.x Since v6.x, some notification functionality was removed, to keep only the basic one. In the documentation they point users to a seperated Library named Notifee.
So you'll find the getBadge-Replacement here
⇓⇓⇓⇓⇓⇓⇓⇓⇓
BUT watch out,
notifee isn't free for production: See Pricelist. So if anybody have suggestions for a free implementation of those badges, feel free to post heres!
来源:https://stackoverflow.com/questions/53854719/how-to-get-a-count-of-the-push-notifications-using-react-native-firebase