最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Web Push Notifications不适用于Firefox,但适用于Chrome和Edge

网站源码admin23浏览0评论

Web Push Notifications不适用于Firefox,但适用于Chrome和Edge

Web Push Notifications不适用于Firefox,但适用于Chrome和Edge

我正在用Heroku编写一个将推送通知发送到Web浏览器的应用程序。我可以100%工作,除了Firefox没有收到任何推送通知。 Chrome和Edge是,但Firefox不是。我确保Firefox允许通知。因此,我的问题不是真的围绕它的编码部分,因为这似乎可以正常工作,但更多的是“在为它开发Web推送通知应用程序时,Firefox有什么我需要注意的东西”吗?我知道每个主流浏览器对待推送通知的方式都有些不同,这就是我怀疑的问题所在。

这是我订阅了推送通知的网站上Firefox的控制台输出。顺便说一下,我在所有浏览器中都收到相同的JSON语法错误-但JSON可以正确解析:

Service worker successfully registered. subscribeUser.js:22:13
email catpured = [email protected] test.html:33:17
Received PushSubscription:  {"endpoint":"","keys":{"auth":"n8yCVyUqhYkOGamajx03Pg","p256dh":"BDgmGLotx4N2BQdqdsIkFjRhycZW1NisTktz-Lyvg094LbDDjMiZEQlLpeuDQCD030Lzx-FleNPewDglpnYS2Wo"}} subscribeUser.js:62:15
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

notificationText Object Stringified: {"notification":{"body":"this is coolfgsdfsfdsfdsdfsdfsfds","title":"Whoa","actions":[{"action":"Yes","title":"Yes","icon":"./images/notification_icon.png"},{"action":"No","title":"No","icon":"./images/notification_icon.png"}],"data":{"url":""},"requireInteraction":true}} service-worker.js:9:11
NotificationText Object Not Stringified:  
Object { notification: {…} }
service-worker.js:10:11
NotificationText.Notification Object:  
Object { body: "this is coolfgsdfsfdsfdsdfsdfsfds", title: "Whoa", actions: (2) […], data: {…}, requireInteraction: true }
service-worker.js:11:11
TypeOf notificationText: object service-worker.js:12:11
Notification:  Whoa

这是Chrome的控制台输出:

email catpured = [email protected]
subscribeUser.js:62 Received PushSubscription:  {"endpoint":":APA91bGTjb4ccnWyiLZ5JIi99rIllciNnnVWt0DvL7emfgpP9Ft_CppxakL_xbB2lH-Xacu1rhov8LXbGCfes4ym0tvObNUSUvwDLA6cr9-0ANSUpUfmLBUq_WxV2DGNTBoDn93jFc8U","expirationTime":null,"keys":{"p256dh":"BMUz_sHi9NWQeuBy5gNmlkPv2PP04A_sbiee01EzuMdCrW14da4r0C2-eVA-tjzNDFxLF1wd1F-I852t8Hl7mb4","auth":"xDNUaKR8gMAhmSG6rbQS5w"}}
test.html:1 Uncaught (in promise) SyntaxError: Unexpected token O in JSON at position 0
Promise.then (async)
sendSubscriptionToBackEnd @ subscribeUser.js:84
(anonymous) @ subscribeUser.js:64
Promise.then (async)
subscribeUserToPush @ subscribeUser.js:61
(anonymous) @ subscribeUser.js:42
Promise.then (async)
askPermission @ subscribeUser.js:41
(anonymous) @ test.html:34
service-worker.js:9 notificationText Object Stringified: {"notification":{"body":"this is coolfgsdfsfdsfdsdfsdfsfds","title":"Whoa","actions":[{"action":"Yes","title":"Yes","icon":"./images/notification_icon.png"},{"action":"No","title":"No","icon":"./images/notification_icon.png"}],"data":{"url":""},"requireInteraction":true}}
service-worker.js:10 NotificationText Object Not Stringified:  {notification: {…}}
service-worker.js:11 NotificationText.Notification Object:  {body: "this is coolfgsdfsfdsfdsdfsdfsfds", title: "Whoa", actions: Array(2), data: {…}, requireInteraction: true}
service-worker.js:12 TypeOf notificationText: object
service-worker.js:15 Notification:  Whoa

这是我收到的有关Chrome的通知:

这是我收到的通知:

回答如下:

答案在这里:https://www.askvg/tip-enable-disable-mozilla-firefox-notifications-to-show-in-windows-10-action-center/。事实证明,默认情况下禁用了Firefox中要在Windows 10操作中心中显示的通知。

发布评论

评论列表(0)

  1. 暂无评论