I can't speak for Workbox as I've never used it but I just setup Push Notification on a project a few weeks ago and I made use of the Web Push Notifications Channel https://github.com/laravel-notification-channels/webpush and this demo of implementing it https://github.com/cretueusebiu/laravel-web-push-demo.
Jan 15, 2019
3
Level 13
Workbox and Push Notification Integration
I'm currently building a progressive web app with Workbox. It's got almost everything working; except that I can't figure out how to integrate push notification.
Here's what I have in my webpack.mix.js
const workboxPlugin = require('workbox-webpack-plugin');
mix.webpackConfig({
plugins: [
new workboxPlugin.InjectManifest({
swSrc: 'public/sw-offline.js', // more control over the caching
swDest: 'sw.js', // the service-worker file name
importsDirectory: 'sw-assets' // have a dedicated folder for sw files
})
]
});
In the sw-offline.js, I define the asset caching policies -
workbox.skipWaiting();
workbox.clientsClaim();
// static
workbox.routing.registerRoute(
new RegExp('.(?:js|css|ico)$'),
workbox.strategies.networkFirst({
cacheName: 'static'
}),
);
Where and how exactly should I integrate the Push API? It's been several hours since I'm investigating this - and there seems to be inadequate information in Google documentation.
Would really appreciate if someone could guide. Thank you in advance.
Please or to participate in this conversation.