【问题标题】:Duplicate messages sending in Firebase Cloud Messaging在 Firebase 云消息传递中发送重复消息
【发布时间】:2020-03-15 21:24:40
【问题描述】:

在我们的项目中,我们使用 Firebase 云消息进行推送通知,但我们遇到了消息重复的问题。我们的流程如下:

  • 我们的客户端基于 iOS 设备,我们使用 follow sdk

Xamarin.Firebase.iOS.CloudMessaging 3.1.2

Xamarin.Firebase.iOS.InstanceID 3.2.1

Xamarin.Firebase.iOS.Core 5.1.3

  • 当用户登录应用程序请求令牌时
  • 应用程序将此令牌发送到订阅此令牌到主题的服务器

为用户订阅主题请求

POST https://iid.googleapis.com/iid/v1:batchAdd
request body   
{
    "to" : "/topics/test",
    "registration_tokens" : ["..user_registration_token.."]
}
  • 服务器定期向主题发送通知

为主题订阅者请求发送通知

POST https://fcm.googleapis.com/v1/projects/our_project_id/messages:send
request body
{
    "message":
    {
        "topic":"test",
        "notification":
        {
            "title":"test-6",
            "body":"test-6"
        }
    }
}
  • 当用户从应用程序中注销时,服务器会从主题中取消订阅用户令牌
POST https://iid.googleapis.com/iid/v1:batchRemove
{
   "to": "/topics/test",
   "registration_tokens" : ["..user_registration_token.."]
}

但是,当用户再次登录并请求全新令牌时,设备仍会收到发送到旧令牌的推送通知,如果我们按主题发送通知,这些用户会收到重复推送通知

如果我们尝试从 api 方法获取旧令牌的信息

GET https://iid.googleapis.com/iid/info/token.....

我们得到回应

<HTML>
  <HEAD>
    <TITLE>Internal Server Error</TITLE>
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
    <H1>Internal Server Error</H1>
    <H2>Error 500</H2>
  </BODY>
</HTML>

【问题讨论】:

    标签: ios xamarin firebase-cloud-messaging


    【解决方案1】:

    尝试将 ?details=true 添加到您的 uri。 请务必在标题中使用授权密钥。 预期输出是

    { "error": "没有找到关于这个实例 id 的信息。" }

    {
        "application": "com.chrome.windows",
        "subtype": "wp:http://localhost:8089/#xxx-xx-xx-xx-xx-x",
        "scope": "*",
        "authorizedEntity": "xxxx",
        "rel": {
            "topics": {
                }
            }
        },
        "platform": "BROWSER"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-07
      • 2017-04-05
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      相关资源
      最近更新 更多