Firebase FCM云消息传递点击动作链接不起作用

发布于 2025-01-18 17:56:04 字数 1500 浏览 0 评论 0原文

我们有一个Angular PWA前端和.NET Core后端,该后端使用Firebase Cloud Mess传递将推送通知发送给最终用户(Web)。

在Angular中,我们使用FCM进行通知。服务工作者按预期工作,以获取前景和背景推送通知。

在Angular中,我们使用使用

对于正常的通知内容(标题,正文,图像)来说,这很好,但我们也想添加也要单击“处理” 。该通知是在后端构建的,并具有以下结构。链接的域与WebApp相同。

var message = new Message()
{
    // Token
    Token = registrationToken,

    // Basic notification template to use across all platforms
    Notification = new Notification
    {
        Title = cloudMessage.Title,
        Body = cloudMessage.Body
    },

    // Webpush protocol options
    Webpush = new WebpushConfig
    {
        FcmOptions = new WebpushFcmOptions
        {
            Link = cloudMessage.Link

        }
    }
};

这就是我们在拦截推送通知时在Chrome Dev中看到的(显然是剥离的数据)。

{
  "from": "",
  "priority": "normal",
  "notification": {
    "title": "Title",
    "body": "Body",
    "click_action": "https://linktoazureapp"
  },
  "fcmMessageId": ""
}

当我们单击通知时,什么也不会发生。我们在不同的操作系统(Windows,Android,iOS)和不同的浏览器(Chrome,Brave,Safari,Firefox)上对此进行了测试,但是结果始终是相同的,单击或敲击通知可以将其删除,而无需采取其他操作。浏览器或PWA打开,待机或完全关闭没有区别。

firebase不会丢下错误,该对象是根据Firebase Cloud Messing的工作方式及其期望来结构的。我们遵循firebase API文档,因此单击通知应打开浏览器或PWA,但无能为力。

We have an Angular PWA frontend and a .Net Core backend, which use Firebase Cloud Messaging for sending push notifications to the end user (web).

In Angular, we use FCM for notifications. The service worker works as expected, for foreground and background push notifications.

In Angular, we use [email protected], in .Net Core, we use [email protected].

This is working fine for normal notification content (title, body, image), but we want to add click handling as well. The notification is build in the backend and has the following structure. The domain of the link is the same as the webapp.

var message = new Message()
{
    // Token
    Token = registrationToken,

    // Basic notification template to use across all platforms
    Notification = new Notification
    {
        Title = cloudMessage.Title,
        Body = cloudMessage.Body
    },

    // Webpush protocol options
    Webpush = new WebpushConfig
    {
        FcmOptions = new WebpushFcmOptions
        {
            Link = cloudMessage.Link

        }
    }
};

This is what we see in Chrome dev when intercepting the push notification (stripped data obviously).

{
  "from": "",
  "priority": "normal",
  "notification": {
    "title": "Title",
    "body": "Body",
    "click_action": "https://linktoazureapp"
  },
  "fcmMessageId": ""
}

When we click the notification, nothing happens. We tested this on different OS (Windows, Android, iOS) and different browsers (Chrome, Brave, Safari, Firefox), but the result is always the same, clicking or tapping the notification removes it and does nothing else. Having a browser or the PWA open, standby or completely closed makes no difference.

Firebase throws no errors, the object is structured according to how Firebase Cloud Messaging works and what it expects. We followed the Firebase API documentation, so clicking the notification should open the browser or PWA, but it does nothing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文