There are many reasons to add a service worker to WordPress: for example you may want to improve caching or add web push notifications. Let’s see how to do that.
A notification that is successfully delivered to the browser push service, may not reach the end user for various reasons:
Are you stuck with an old version of the service worker or your imported scripts are not being updated as you expect? This guide shows you how to ensure that your service worker and the imported scripts are updated in a timely manner.
Usually the prompt for web push notifications is displayed only once, the first time that the user visits a website. What if the user blocks the notifications? Is there a way to show the notifications prompt when the user visits the website again?
This article investigates one of the reasons that negatively impact delivery rates for web push. First it shows that web push subscriptions can last many years without expiring, then it proves a negative correlation between the age of a web push subscription and its expected delivery rate.
There are various reasons that can prevent a web push notification from being delivered. One of them is the presence of subscriptions that are no longer in use:
You can use web push notifications to re-engage your users in many different ways. For example you can send transactional notifications to specific users when something happen or you can send large campaigns to all your subscribers. However in this tutorial we show a way to send notifications specifically to users who become inactive.
Forcing the user to subscribe to push notifications is probably not a good choice for most websites. However there are some specific situations where it makes sense to do that.
You can change your notification preferences for a website at any time. You can allow or block the notifications using the browser preferences: