(wip) PWA Push Notifications
This commit is contained in:
@ -1,34 +1,37 @@
|
||||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js');
|
||||
// importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js');
|
||||
|
||||
// Only import the modules you need; skip precaching and routing if not needed
|
||||
workbox.core.skipWaiting();
|
||||
workbox.core.clientsClaim();
|
||||
// // ToDo: probably not used now as we use next-pwa( check config)
|
||||
// // Only import the modules you need; skip precaching and routing if not needed
|
||||
|
||||
//workbox.precaching.cleanupOutdatedCaches();
|
||||
//disable precaching
|
||||
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
|
||||
// workbox.core.skipWaiting();
|
||||
// workbox.core.clientsClaim();
|
||||
|
||||
module.exports = {
|
||||
// Other webpack config...
|
||||
plugins: [
|
||||
// Other plugins...
|
||||
new InjectManifest({
|
||||
// These are some common options, and not all are required.
|
||||
// Consult the docs for more info.
|
||||
exclude: [/.../, '...'],
|
||||
maximumFileSizeToCacheInBytes: 1 * 1024 * 1024,
|
||||
swSrc: './worker/index.js',
|
||||
}),
|
||||
],
|
||||
};
|
||||
// //workbox.precaching.cleanupOutdatedCaches();
|
||||
// //disable precaching
|
||||
// workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
// Example: Set up push notification handling
|
||||
self.addEventListener('push', event => {
|
||||
const data = event.data.json();
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title, {
|
||||
body: data.message,
|
||||
icon: '/path/to/icon.png'
|
||||
})
|
||||
);
|
||||
});
|
||||
// module.exports = {
|
||||
// // Other webpack config...
|
||||
// plugins: [
|
||||
// // Other plugins...
|
||||
// new InjectManifest({
|
||||
// // These are some common options, and not all are required.
|
||||
// // Consult the docs for more info.
|
||||
// exclude: [/.../, '...'],
|
||||
// maximumFileSizeToCacheInBytes: 1 * 1024 * 1024,
|
||||
// // swSrc: './worker.js',
|
||||
// }),
|
||||
// ],
|
||||
// };
|
||||
|
||||
// // Example: Set up push notification handling
|
||||
// self.addEventListener('push', event => {
|
||||
// console.log('Push event received at workbox.config: ', event);
|
||||
// const data = event.data.json();
|
||||
// event.waitUntil(
|
||||
// self.registration.showNotification(data.title, {
|
||||
// body: data.message,
|
||||
// icon: '/path/to/icon.png'
|
||||
// })
|
||||
// );
|
||||
// });
|
||||
|
Reference in New Issue
Block a user