[英]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 帖子后,我尝试了以下方法:
https
domainhttps
域后面发送通知 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.