[英]After accepting web notifications, can a website send notifications when browser has no tab open of this website?
I am reading the Web notification API and I want to send notification like they are on iOS or Android (ex: You have 7 new messages
). I am reading the Web notification API and I want to send notification like they are on iOS or Android (ex:
You have 7 new messages
).
Considering I have accepted notification from www.my-foobar-super-site.com
, can I, after authorizing notification from it , can my website send Web notification to a user when this user has no tabs open of this website?考虑到我已经接受了来自
www.my-foobar-super-site.com
通知,我可以在授权通知后,当该用户没有打开该网站的标签时,我的网站可以向用户发送 Web 通知吗?
After accepting web notifications, can a website send notifications when browser has no tab open of this website?
接受web通知后,网站在浏览器没有打开该网站的标签时可以发送通知吗?
Yes, but there's more to it than just a user granting the notifications permission.是的,但它不仅仅是授予通知权限的用户。
The Web Notifications API is only concerned with displaying messages on-screen from a script already running on the user's computer, it is unrelated to "push notifications" or delivery. Web 通知 API 只关心在屏幕上显示来自用户计算机上已经运行的脚本的消息,它与“推送通知”或传递无关。
To send "push" messages to a user's browser, you'll need to use the separate Push API - and run a Service Worker to receive messages from your service (via the Push API) and only then can your script use the Notifications API to show the notification message.要将“推送”消息发送到用户的浏览器,您需要使用单独的 Push API - 并运行 Service Worker 以从您的服务接收消息(通过 Push API),然后您的脚本才能使用通知 API 来显示通知消息。
Yes, as long as you have registered a service worker.可以,只要您注册了 Service Worker。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.