在我们的项目中,我们使用Firebase云消息传递来进行推送通知,我们遇到了消息重复的问题。我们过程如下所示:
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>
尝试在URI中添加?details=true。请确保在标题中使用授权密钥。预期输出为
null
或
{
"application": "com.chrome.windows",
"subtype": "wp:http://localhost:8089/#xxx-xx-xx-xx-xx-x",
"scope": "*",
"authorizedEntity": "xxxx",
"rel": {
"topics": {
}
}
},
"platform": "BROWSER"
}