Native Push Notifications Support for NodeBB
-
@phenomlab clearing the browser cache wouldn't actually remove the service worker, unfortunately.
It's proving surprisingly hard to find instructions to teach people how to clear the existing service worker
Chrome, at least, will check for a new one after 24 hours I think .
-
@julian OK. Still no activity for me though despite updates here. Did you also remove ntfy as that isn't issuing alerts anymore.
A bit greedy, but this
js
would probably workif ('serviceWorker' in navigator) { caches.keys().then(function(cacheNames) { cacheNames.forEach(function(cacheName) { caches.delete(cacheName); }); }); }
Or perhaps this header
Cache-Control: no-cache,no-store,must-revalidate
Or this modified
js
function async deleteCaches() { try { const keys = await window.caches.keys(); await Promise.all(keys.map(key => caches.delete(key))); } catch (err) { console.log('deleteCache err: ', err); } } // run this function on your app load function resetCacheForUpdate() { if (!localStorage.getItem('cacheReset')) { deleteCaches() .then(_ => { localStorage.setItem('cacheReset', 'yes'); }) } }
Source
Service Worker Cache Busting
Learn how to publish the latest version of your progressive web app.
Jun711 blog (jun711.github.io)
-
@phenomlab It is not the service worker cache that is at fault, it's the fact that the service worker itself is outdated on your machine
But that will resolve over time, and I will look into further strategies.
That said, twice already I've lost my subscription to the push service. Will have to dig into it and see what error is thrown.
-
-
The web-push plugin has now been promoted in v4 beta to "bundled" status, with a corresponding demotion of the ntfy plugin.
fix(deps): swap ntfy for web-push plugin ยท NodeBB/NodeBB@aa060d3
Node.js based forum software built for the modern web - fix(deps): swap ntfy for web-push plugin ยท NodeBB/NodeBB@aa060d3
GitHub (github.com)
-
@phenomlab glad to hear you found it
For those interested in updating, you can just grab the latest commit from
activitypub
branch or perhaps the more the specific commit:git fetch git checkout activitypub # if you're not already on activitypub branch git reset --hard 86f624f8172fb96fbd3c83683affd8814e8b5156`
-
@phenomlab There's not terribly much to configure, just make sure that when you start NodeBB, that you see the output
info: [plugins/web-push] VAPID keys OK.
That's how the messages are encoded to be sent to the corresponding browser push endpoints.
Other than that make sure the user has toggled push notifications on in their settings and allowed notifications for the site.
On Windows, you have to specifically also allow your browser access to send notifications to the user.
-
v0.7.0 of the Push Notification plugin has been released
- Notification related service worker code that was initially included in v4 core is now served by the web-push plugin directly, allowing v3.x compatibility.
- Compatibility updated from v4 to v3.10.x
- Meaning if you want to try this out on your existing NodeBB, you can do so by either waiting for v3.10.0, or by updating to the latest commit on the
develop
branch
- Meaning if you want to try this out on your existing NodeBB, you can do so by either waiting for v3.10.0, or by updating to the latest commit on the