PWA is not working after installing webpushr service worker

Hi, the PWA is not working in my website after installing the webpushr service worker file.
Is there any reason behind it?
I believe this is because of my default PWA offline service worker. It looks like this…

'use strict';
const CACHE_VERSION=1;
let CURRENT_CACHES={offline:"offline-v1"};
const OFFLINE_URL="/offline.html";
function createCacheBustedRequest(a){let b=new Request(a,{cache:"reload"});if("cache"in b)return b;let c=new URL(a,self.location.href);return c.search+=(c.search?"&":"")+"cachebust="+Date.now(),new Request(c)}self.addEventListener("install",a=>{a.waitUntil(fetch(createCacheBustedRequest(OFFLINE_URL)).then(function(a){return caches.open(CURRENT_CACHES.offline).then(function(b){return b.put(OFFLINE_URL,a)})}))}),self.addEventListener("activate",a=>{let b=Object.keys(CURRENT_CACHES).map(function(a){return CURRENT_CACHES[a]});a.waitUntil(caches.keys().then(a=>Promise.all(a.map(a=>{if(-1===b.indexOf(a))return console.log("Deleting out of date cache:",a),caches.delete(a)}))))}),self.addEventListener("fetch",a=>{("navigate"===a.request.mode||"GET"===a.request.method&&a.request.headers.get("accept").includes("text/html"))&&(console.log("Handling fetch event for",a.request.url),a.respondWith(fetch(a.request).catch(a=>(console.log("Fetch failed; returning offline page instead.",a),caches.match(OFFLINE_URL)))))});

Hi,

We offer compatibility with multiple PWA plugins. Did you read this Webpushr compatibility with PWA Plugins

Which PWA plugin you are using?

I’m not using any plugins. It’s custom using Cloudflare worker. I didn’t know that it’s not possible to have more than one service worker. Is there any way to fix it?

You can import the Webpushr’s service worker by adding the following line into your service worker

importScripts(‘https://cdn.webpushr.com/sw-server.min.js’);

and replace the service worker path to none in the Webpushr JS code snippet like below

webpushr(‘setup’,{ ‘key’ : ‘YOUR-KEY’, ‘sw’ : ‘none’ });

Let me know if this solution works for you.

Unfortunately it didn’t work for me either. It says Service Worker script evaluation failed.

Can you please share your website URL so that we can check?

I just visited your website and did not find your custom Service worker instead only Webpushr service worker is installed and Webpushr is working as excepted.

Did you checked this URL - eracorner.com/sw.js

You should stop registering your Service Worker and add the code of your service worker https://www.eracorner.com/sw.js into Webpushr’s service worker https://www.eracorner.com/webpushr-sw.js file

Thanks! :raised_hands: Now working fine.