简体   繁体   中英

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 ).

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?

After accepting web notifications, can a website send notifications when browser has no tab open of this website?

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.

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.

Yes, as long as you have registered a service worker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM