Android Chrome does not automatically update service worker

449 Views Asked by At

I have a simple PWA in which push notifications are sent out daily. Push messages are turned into notifications through the following more or less trivial service worker:

self.addEventListener("push", function(event) {
    if (event.data) {
        data = event.data.json()
        showLocalNotification("Test title", data.message, self.registration);
    }
});

const showLocalNotification = (title, body, swRegistration) => {
    const options = {
        body: body,
        icon: "/plug-512.png",
    };
    swRegistration.showNotification(title, options);
};

// Chrome unfortunately requires a fetch event handler to be in place for an app to be
// considered "installable", even if there is no reason to handle the event. We get around
// this by simply adding a trivial handler.
self.addEventListener('fetch', function() {});

Now, according to the documentation, an update is triggered, in case of

A functional events such as push and sync, unless there's been an update check within the previous 24 hours.

If I'm reading this correctly, this means that if I change "Test title" to something else, then within at most 2 daily push notifications, the title should change in the notification received by the app's users, since then, at least 24 hours have passed, and we've received a functional event. However, the title is in fact left unchanged even after 2 daily notifications (although in my test, it did update upon the third notification, roughtly 60 hours after the change to the service worker).

So, am I misreading the documentation, or is this simply a bug in Android Chrome?

0

There are 0 best solutions below