Send desktop notifications in Chrome or Firefox from a closed web app?

后端 未结 2 622
南方客
南方客 2020-11-30 18:20

My goal is to send Gmail-style desktop notifications in Chrome or Firefox from a web app (let\'s call it X) that is NOT currently open in the browser, without requiring the

相关标签:
2条回答
  • 2020-11-30 18:41

    You can send push notifications even when your web page is not active using Service Workers, the Notification API for service workers and the push API for server-initiated notifications (or scheduled notifications).

    As of June 2016, Service Workers are supported in Chrome, Firefox and Opera. See the status at https://jakearchibald.github.io/isserviceworkerready/

    See the following links for related discussions, status of implementation and specifications.

    • Service workers are enabled by default since Chrome 40, Firefox 33, and Opera 24. See the HTML5Rocks tutorial and MDN.
    • Push notifications: Chrome 42+, Firefox 44+
    0 讨论(0)
  • 2020-11-30 18:50

    You can do exactly what you are looking for using the W3C Push API.

    If you want to build everything from scratch I suggest to start reading this tutorial by Google. It is for Chrome, but Firefox works in a very similar way.

    However it's a lot of work and the "standard" is still evolving: I suggest that you use a service like Pushpad (I am the founder).

    0 讨论(0)
提交回复
热议问题