Search code examples
flutterfirebasefirebase-cloud-messagingbadge

Flutter fcm push notifications are not able to show icon badges


final data = { "notification": { "title": title, "body": body, }, "apns": { "payload": { "aps": {"badge": 1} } }, "to": pid };


Solution

  • When you receive your payload data you have to update the badge manually when you are using Flutter.

    Integrate this library in your code so it can manage it easily

    All you have to do is read the badge that is coming inside the FCM body from the following code block and increase the badge depending on that number OR just increase the badge every time you receive a new notification:

    FirebaseMessaging.onMessage.listen((RemoteMessage message) {
      print('Got a message whilst in the foreground!');
      print('Message data: ${message.data}');
    });