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

梦想的初衷 提交于 2020-08-24 04:49:30

问题


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,
};

I saw the react-native answer for this, but there is no way to do the same thing using firebase_messaging plugin react native answer


回答1:


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.



来源:https://stackoverflow.com/questions/63271091/is-it-possible-to-implement-notification-grouping-bundling-using-fcm-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!