小编Fer*_*tos的帖子

收到两次推送通知

我们已经在我们的应用程序中使用 Firebase 发送推送通知几个月了,我也在我的其他应用程序中使用了它。一切都很顺利,但是一周前我们开始收到重复的通知(并非总是如此)。奇怪的是,我们没有更改任何代码,它只是在 Android 和 iOS 中开始发生。它只是有时发生,并非总是发生,并且仅在某些用户/设备中发生。

我想知道是否有其他人正在使用 Firebase 经历这种情况。我认为这是一个 Firebase 错误,但我想看看是否有人可以确认相关内容。

ios 应用程序是用 swift 编写的,android 应用程序是用 Java 编写的。

顺便提一句。我们将基于此通过后端的 FCM 发送它。而且我们没有重复的主题。我检查过,设备只订阅一次。

https://fcm.googleapis.com/fcm/send

Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
  "to": "/topics/foo-bar",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
   }
}
Run Code Online (Sandbox Code Playgroud)

这是我在后端发送通知的 C# 代码

public void sendPushNotification(string _title, string _message, string _topic, object customData = null)
    {
        var requestUri = "https://fcm.googleapis.com/fcm/send";

        WebRequest webRequest = WebRequest.Create(requestUri);
        webRequest.Method = "POST";
        webRequest.Headers.Add(string.Format("Authorization: key={0}", FCM_SERVER_API_KEY));
        webRequest.Headers.Add(string.Format("Sender: id={0}", FCM_SENDER_ID));
        webRequest.ContentType = "application/json";

        var data = …
Run Code Online (Sandbox Code Playgroud)

c# push-notification firebase firebase-cloud-messaging

5
推荐指数
0
解决办法
2330
查看次数