Is it possible to implement notification grouping/bundling using FCM in Flutter?

Viewed 3346

I try to implement group notification like this android group notification and ios group notification. But I can't able to do it. I tried this flutter_local_notification plugin too. but this works only when app open. not working on foreground(onResume) and background.

  void registerNotification() {
    
    _fcm.configure(
        onMessage: (Map<String, dynamic> message) {
          return;
        },
        onResume: (Map<String, dynamic> message) {
            return;
        },
        onLaunch: (Map<String, dynamic> message) {
          return;
        },
        onBackgroundMessage: backgroundMessageHandler);
  }

payload

const payload = {
  notification: {
    title: title,
    body: message,
  },
  data: {
    click_action: "FLUTTER_NOTIFICATION_CLICK",
    sound: "default"
  },
  android: {
    priority: "high",
    collapse_key: userName,//tried to add collapse_key for group notification
  },
  apns: {
    headers: {
      "apns-priority": "5",
    },
  },
  token:token,
};

SOLUTION

I saw the react-native answer for this, you have to do same thing using Flutter with firebase_messaging react native answer

1 Answers

If you want to submit a group, you need to subscribe to a topic, in the documentation that mentions it, you would no longer send a single token, but would instead subscribe to a topic and submit it to that topic.

Related