App icon badge - Firebase push notification /FCM - Flutter

7,167

You can add "badge" option to notification payload.

ref: https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support

Share:
7,167
shruti tupkari
Author by

shruti tupkari

Updated on November 28, 2022

Comments

  • shruti tupkari
    shruti tupkari over 1 year

    I want to show notification counter on my app icon. I need to do it for both iOS and Android. Also counter must update when App is killed(not running) or when running in background. I am using firebase push notifications.

    If I consider using common counter then I can use FirebaseMessaging.configure onMessage event to decrease the counter value, but how to increase the value of the same counter (how will I know that notification is received).

    flutter_app_badger 1.1.2 description showing increasing and decreasing counter value on button press, how can I listen to notification and handle counter?

    Below is my Message Payload

        var tokens = [];
    var payload = {
        "notification": {
            "title": "Contest Won! " + contestActivityFeedData.contestname,
            "body": "You Have Won " + contestActivityFeedData.amount,
            "click_action": "FLUTTER_NOTIFICATION_CLICK",
        },
        "data": {
            "contestid": contestActivityFeedData.contestid,
            "contestname": contestActivityFeedData.contestname,
            "notificationtype": 'contest_won'
        },
    }
    admin.messaging().sendToDevice(tokens, payload);
    

    Any article/video/plugin for this?

    This is what i am trying to achieve