<tfoot id='0Lxuw'></tfoot>

      <legend id='0Lxuw'><style id='0Lxuw'><dir id='0Lxuw'><q id='0Lxuw'></q></dir></style></legend>

        <bdo id='0Lxuw'></bdo><ul id='0Lxuw'></ul>
      <i id='0Lxuw'><tr id='0Lxuw'><dt id='0Lxuw'><q id='0Lxuw'><span id='0Lxuw'><b id='0Lxuw'><form id='0Lxuw'><ins id='0Lxuw'></ins><ul id='0Lxuw'></ul><sub id='0Lxuw'></sub></form><legend id='0Lxuw'></legend><bdo id='0Lxuw'><pre id='0Lxuw'><center id='0Lxuw'></center></pre></bdo></b><th id='0Lxuw'></th></span></q></dt></tr></i><div id='0Lxuw'><tfoot id='0Lxuw'></tfoot><dl id='0Lxuw'><fieldset id='0Lxuw'></fieldset></dl></div>

      <small id='0Lxuw'></small><noframes id='0Lxuw'>

      像whatsapp这样的组fcm通知,但允许多个组通知

      Group fcm notifications like whatsapp but allowing multiple group notifications(像whatsapp这样的组fcm通知,但允许多个组通知)

        <legend id='FtdtG'><style id='FtdtG'><dir id='FtdtG'><q id='FtdtG'></q></dir></style></legend>
        • <i id='FtdtG'><tr id='FtdtG'><dt id='FtdtG'><q id='FtdtG'><span id='FtdtG'><b id='FtdtG'><form id='FtdtG'><ins id='FtdtG'></ins><ul id='FtdtG'></ul><sub id='FtdtG'></sub></form><legend id='FtdtG'></legend><bdo id='FtdtG'><pre id='FtdtG'><center id='FtdtG'></center></pre></bdo></b><th id='FtdtG'></th></span></q></dt></tr></i><div id='FtdtG'><tfoot id='FtdtG'></tfoot><dl id='FtdtG'><fieldset id='FtdtG'></fieldset></dl></div>
            <bdo id='FtdtG'></bdo><ul id='FtdtG'></ul>

            <small id='FtdtG'></small><noframes id='FtdtG'>

                <tbody id='FtdtG'></tbody>

                <tfoot id='FtdtG'></tfoot>
                本文介绍了像whatsapp这样的组fcm通知,但允许多个组通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我不确定这是否完全可能,但我会说明我的要求.如果可能的话,请帮我弄清楚该怎么做.

                I am not sure whether this is entirely possible but I'll state my requirement. If it is possible then kindly help me figure out how to do it.

                假设我有一个画廊类型的 Android 应用程序.当用户喜欢或评论图库中的照片时,我们会使用下面给出的代码触发 fcm 通知

                Let's say I have a gallery kind of an android app. When the user likes or comments on a photo in the gallery, We'd trigger an fcm notification using the code given below

                    value++;
                    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                            .setSmallIcon(R.drawable.notification)
                            .setLargeIcon(rawBitmap)
                            .setContentTitle("MyApp")
                            .setContentText(ContentText)
                            .setAutoCancel(true)
                            .setSound(defaultSoundUri)
                            .setDefaults(Notification.DEFAULT_SOUND)
                            .setStyle(new NotificationCompat.BigTextStyle().bigText(ContentText))
                            .setContentIntent(pendingIntent);
                
                    NotificationManager notificationManager =
                            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                
                    notificationManager.notify(value, notificationBuilder.build());
                

                通过添加 InboxStyle,我们可以将通知分组为一个并增加计数.(例如,您有 5 个通知)

                By adding InboxStyle we can group notifcations into a single one and just increase the count.(For e.g. You have 5 notifications)

                      NotificationCompat.InboxStyle inboxStyle =
                                new NotificationCompat.InboxStyle();
                            // Sets a title for the Inbox in expanded layout
                            inboxStyle.setBigContentTitle("Title - Notification");
                            inboxStyle.setSummaryText("You have "+value+" Notifications.");
                            notificationBuilder.setStyle(inboxStyle);
                

                但我的要求就像为单独的照片单独分组.如果用户留下 2 条评论,每条评论 3 张照片.我需要列出三组通知.更像是您对这张照片有 2 条评论,对这张照片有 2 条评论,以此类推.

                But my requirement is like separate grouping for separate photos. If the user leaves 2 comments each for 3 photos. I need three groups of notifications to be listed. More like you have 2 comments on this photo,2 on this and so on.

                如果有帮助,我会收到照片的唯一 ID.

                I'll be receiving unique ids for the photos,if that helps.

                How long will the id be retained?
                

                假设用户对 id 为 001 的照片发表了 2 条评论,而合作伙伴作为一个群组收到通知.

                Let's assume the user drops 2 comments on photo with id 001 and the partner receives the notification as a group .

                What happens when the user drops another 2 comments on photo with id 002?
                Will there be 2 groups?
                

                因为一组 id 为 001 的通知保持不变.

                Because a group of notification with id 001 remains untouched.

                推荐答案

                我会使用 TAG 参数.对于每组消息,您应该使用不同的 TAG.

                I would use the TAG parameter. For each group of messages you should use a different TAG.

                例如:

                消息 1)

                {
                    "notification": {
                        "title": "PhotoApp: photo 123",
                        "body": "You have 1 notification",
                        "click_action" : "OPEN_MAINACTIVITY",
                        "icon": "ic_launcher",
                        "color": "#ffffff"
                        "tag": "photo123"
                    },
                    "registration_ids":[
                        "--your_id--"
                    ]
                }
                

                消息 2)

                {
                    "notification": {
                        "title": "PhotoApp: photo ABC",
                        "body": "You have 1 notification",
                        "click_action" : "OPEN_MAINACTIVITY",
                        "icon": "ic_launcher",
                        "color": "#ffffff"
                        "tag": "photoABC"
                    },
                    "registration_ids":[
                        "--your_id--"
                    ]
                }
                

                消息 3)

                {
                    "notification": {
                        "title": "PhotoApp: photo 123",
                        "body": "You have 2 notifications",
                        "click_action" : "OPEN_MAINACTIVITY",
                        "icon": "ic_launcher",
                        "color": "#ffffff"
                        "tag": "photo123"
                    },
                    "registration_ids":[
                        "--your_id--"
                    ]
                }
                

                这将仅显示 2 个通知警报.一个用于 Photo123,显示有 2 个通知(最后一条消息),另一个用于 PhotoABC,显示只有 1 个通知.

                This will show only 2 notification alerts. One for Photo123, showing there are 2 notifications (last message), and the other for PhotoABC, showing there is just 1 notification.

                这里最重要的是TAG参数.它会根据需要对通知进行分组,

                The most important thing here is the TAG parameter. It will group notifications as you need,

                希望我明确表示对您有所帮助.

                Hope I made myself clear at it helps you out.

                一些有用的链接:

                FCM 文档

                类似的问题

                这篇关于像whatsapp这样的组fcm通知,但允许多个组通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                When does a FCM token expire?(FCM 令牌何时到期?)
                Firebase Cloud Messaging (FCM) - Launch Activity when user clicks the notification with extras(Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动)
                Implement Firebase inside of a Library(在库中实现 Firebase)
                Firebase Backward compatibility with GCM(Firebase 与 GCM 的向后兼容性)
                Receiving the FCM notifications multiple times on Nougat(在 Nougat 上多次接收 FCM 通知)
                Push Notifications are delivered but didReceiveRemoteNotification is never called Swift(推送通知已交付,但 didReceiveRemoteNotification 从未被称为 Swift)

              1. <tfoot id='kgXrD'></tfoot>

                <i id='kgXrD'><tr id='kgXrD'><dt id='kgXrD'><q id='kgXrD'><span id='kgXrD'><b id='kgXrD'><form id='kgXrD'><ins id='kgXrD'></ins><ul id='kgXrD'></ul><sub id='kgXrD'></sub></form><legend id='kgXrD'></legend><bdo id='kgXrD'><pre id='kgXrD'><center id='kgXrD'></center></pre></bdo></b><th id='kgXrD'></th></span></q></dt></tr></i><div id='kgXrD'><tfoot id='kgXrD'></tfoot><dl id='kgXrD'><fieldset id='kgXrD'></fieldset></dl></div>

                <small id='kgXrD'></small><noframes id='kgXrD'>

                      <tbody id='kgXrD'></tbody>

                      <bdo id='kgXrD'></bdo><ul id='kgXrD'></ul>
                          <legend id='kgXrD'><style id='kgXrD'><dir id='kgXrD'><q id='kgXrD'></q></dir></style></legend>