简体   繁体   English

推送通知在 Firefox 中有效,但在 React 应用程序中的 Chrome 中无效

[英]Push notifications working in Firefox but not Chrome in React app

I am working on implementing push notifications for my React app.我正在为我的 React 应用程序实现推送通知。 It is working fine in Firefox - ie the notification popup appears, but the notification popups do not appear in Chrome.它在 Firefox 中工作正常 - 即出现通知弹出窗口,但通知弹出窗口不会出现在 Chrome 中。 Here is my code that handles receiving a notification:这是我处理接收通知的代码:

function receivePushNotification(event) {
  console.log("====> Service worker received notification"); // This logs out in Chrome and Firefox
  event.waitUntil(self.registration.showNotification("Sample title", {}));
}

The console.log in the function prints fine so I know for a fact that the notification made it into the browser. function 中的console.log打印正常,所以我知道通知已进入浏览器。 I am not sure why event.waitUntil(self.registration.showNotification("Sample title", {}));我不知道为什么event.waitUntil(self.registration.showNotification("Sample title", {})); does not show the notification in Chrome.不在 Chrome 中显示通知。

After looking at similar SO posts, I have tried the following:在查看了类似的 SO 帖子后,我尝试了以下方法:

  • Deployed my server that actually sends the notification behind a https domain部署了我的服务器,它实际上在https域后面发送通知
  • Made sure that the public key is correct确保公钥正确
  • Made sure that Chrome allows notifications:确保 Chrome 允许通知:

在此处输入图像描述

I am not sure what else I can do or check.我不确定我还能做什么或检查。 Does anyone have any ideas on what else I can do or check?有人对我还能做什么或检查什么有任何想法吗? Any help would be greatly appreciated!任何帮助将不胜感激!

OK so it appears that in addition to enabling notifications in the browser, I also had to enable notifications on my computer (mac) itself:好的,看来除了在浏览器中启用通知外,我还必须在我的计算机(mac)本身上启用通知:

System Preferences > Google Chrome > ALLOW NOTIFICATIONS FROM GOGOLE CHROME : System Preferences > Google Chrome > ALLOW NOTIFICATIONS FROM GOGOLE CHROME

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FCM通知适用于Chrome,但不适用于Firefox - FCM notifications working on Chrome but not on Firefox Chrome和Firefox OS实现中的Push Notifications API是否具有相同的标准? - Are the Push Notifications APIs in Chrome and Firefox OS implementations of the same standard? Clevertap Web push在Firefox和Chrome 71上不起作用 - Clevertap web push not working on Firefox and Chrome 71 未安装应用程序时 PWA 推送通知不起作用 - PWA push notifications not working when app is not installed Expo 推送通知不适用于 Android 独立应用程序 - Expo push notifications not working on Android standalone app Web通知无法在chrome上运行,但在Firefox和Microsoft Edge上可以正常运行 - Web notifications is not working on chrome, but it's working fine on firefox and microsoft edge Web Chrome 中的推送通知 - Web push notifications in chrome React 应用程序在 Safari 中不起作用。 在 Chrome 和 FireFox 上工作正常,但为 safari 提供黑色布局 - React app not working in Safari. Working fine on Chrome and FireFox but giving black layout for safari 我如何在Angle App中订阅/收听Chrome推送通知 - How can i subscribe/listen to chrome push notifications in angular app focus() 在 Chrome 和 Firefox 上的 React 代码盒中没有真正工作 - focus() not really working in a React codesandbox on Chrome and Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM