• service-worker.js

  • Register event listener for the ‘push’ event.

    self.addEventListener('push', function(event) {
  • Keep the service worker alive until the notification is created.

      event.waitUntil(
  • Show a notification with title ‘ServiceWorker Cookbook’ and body ‘Alea iacta est’.

        self.registration.showNotification('ServiceWorker Cookbook', {
          body: 'Alea iacta est',
        })
      );
    });

Has it been useful?

Tell us what you think of this recipe by leaving a comment!