In order to replace old notifications, we can use the notification tag. This will help us show up-to-date information to the user.
This recipe will show you how to manage a queue of notifications and discard previous notifications or merge them into a single notification.
To get started with service workers, you will need to have the service worker experiment feature turned on in your browser settings. If you have not done this yet, refer to the first recipe of Chapter 1, Learning Service Worker Basics: Setting up service workers. Service workers only run across HTTPS. To find out how to set up a development environment to support this feature, refer to the Setting up GitHub pages for SSL recipe of Chapter 1, Learning Service Worker Basics.
Follow these instructions to set up your file structure:
Copy the
index.html
,index.js
,service-worker.js
,manifest.json
,server.js
,package.json
, andstyle.css
files from the following location: