【问题标题】:Firebase sending multiple push notifications instead of stacking or replacingFirebase 发送多个推送通知,而不是堆叠或替换
【发布时间】:2016-10-07 18:32:05
【问题描述】:

我正在尝试使用新的推送通知堆栈或将其替换为 android 的系统托盘。

我不确定如何执行此操作,因为推送通知正在发回数据和通知对象,据我所知,通知直接发送到系统托盘。如果是这样,我如何阻止通知独立出现。一些用户会收到 5-10 条通知,并且会一直向上推送。

编辑:

我尝试了collapse_key,但它仍然不能用相同的键替换之前的通知......我在这里做错了吗?

method: 'POST',
                            uri: 'https://gcm-http.googleapis.com/gcm/send',
                            headers: {
                                'Content-Type': 'application/json',
                                'Authorization': authorize //GOOGLE API KEY
                            },

                            body: JSON.stringify({
                                "registration_ids": [otherUserResult.reg_id],

                                "collapse_key": "follow",
                                "data": {
                                    "notifyToUserId": to,
                                    "notifyFromId": from,
                                    "notifyMsg": msg,
                                    "notifyItemPicture": itemPic,
                                    "notifyItemName": itemName,
                                    "notifyFromName": fromName,
                                    "notifyType": type,
                                    "dateNotified": dateNotified


                                },
                                "notification": {
                                    "title": fromName,
                                    "body": notifyMsg,
                                    "icon"  : "ic_pushnotify"
                                },
                                "priority": "high",
                                "content_available": true

【问题讨论】:

  • 您正在寻找所谓的可折叠消息。见firebase.google.com/docs/cloud-messaging/…
  • 我正在尝试添加 "collapse_key": "follow" 但它仍然显示为新消息
  • @frankvanpuffelen 我添加了我的消息,如果我搞砸了,请告诉我
  • 尝试在你的 uri 中使用新的 fcm 端点:https://fcm.googleapis.com/fcm/send 看看是否有什么不同。
  • 没有区别,但谷歌表示他们相应地重定向并不重要

标签: android firebase push-notification notifications firebase-notifications


【解决方案1】:

当我在“通知”中包含 2 行时,我工作了:

collapse_key: 'your_app_unique_string',
tag: 'your_app_unique_string'

所以完整的代码是:

var payload = {notification: {
                                        title: "Mensaje de "+message.name,
                                        body: message.text,
                                        sound: "default",
                                        collapse_key: 'charlero',
                                        tag: 'charlero'
                                    }
                                };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多