A
A
alex_kulkoff2019-03-25 13:42:34
Vue.js
alex_kulkoff, 2019-03-25 13:42:34

Push notifications via web-push and Vue how to fix service-worker?

The essence of the question is how to test on a local computer. I use vue-cli. In the developer console, service-worker.js looks somehow default. How can it be changed? Here is an example file:

/* global self */

// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.

// It is read and returned by a dev server middleware that is only loaded
// during development.

// In the production build, this file is replaced with an actual service worker
// file that will precache your site's local assets.

self.addEventListener('install', () => self.skipWaiting())

self.addEventListener('activate', () => {
  self.clients.matchAll({ type: 'window' }).then(windowClients => {
    for (const windowClient of windowClients) {
      // Force open pages to refresh, so that they have a chance to load the
      // fresh navigation response from the local dev server.
      windowClient.navigate(windowClient.url)
    }
  })
})

It turns out that I set up everything except for receiving the notification itself, or rather, I even receive it from the backend, but I can’t show it, because I have a default service-worker

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question