【问题标题】:FCM: How to avoid duplicate notifications if a user has subscribed to multiple topicsFCM:如果用户订阅了多个主题,如何避免重复通知
【发布时间】:2016-11-24 07:24:56
【问题描述】:

假设用户 A 订阅了主题 T1、T2 和 T3。

如果我向主题 T1 和 T3 发送相同的通知。 A 会收到两个通知吗?

如果是,如何避免这种重复的通知?

谢谢

【问题讨论】:

    标签: firebase firebase-cloud-messaging firebase-notifications subscribe


    【解决方案1】:

    您必须一次将通知发送到多个主题,如 firebase 文档所示:

    https://fcm.googleapis.com/fcm/send
    Content-Type:application/json
    Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
    {
      "condition": "'dogs' in topics || 'cats' in topics",
      "data": {
        "message": "This is a Firebase Cloud Messaging Topic Message!",
      }
    }
    

    更多细节在这里: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

    【讨论】:

    • 很遗憾,此功能仅限于 5 个主题。有什么方法可以发送超过 5 个主题而不发送重复?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 2021-08-29
    • 2019-12-21
    • 2023-03-23
    • 2018-06-17
    • 2019-04-13
    相关资源
    最近更新 更多