Title: Notifications problem
Last modified: July 14, 2021

---

# Notifications problem

 *  [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/)
 * Hello!
 * I use OneSignal notifications in my PWA.
    – Chrome: I get a notification and 
   it opens a PWA – Firefox: I get a notification but it comes from the browser 
   and it does open a browser instead of PWA. – Edge: no notification at all.
 * All tests was done on Android 11.
 * Is this problem related to this plugin or OneSignal?
 * Best,
    Juuso

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14663317)
 * Can you please share the short video of the issue which you are encountering 
   at your end along with the URL of the website? So that we will also check this
   from our end and get back to you accordingly.
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14698344)
 * Hello!
 * Sorry for the delay… But here’s the video now: [https://drive.google.com/file/d/17VOfcAEhtrXjA1v5x3RwAybDWc559ihi/view?usp=sharing](https://drive.google.com/file/d/17VOfcAEhtrXjA1v5x3RwAybDWc559ihi/view?usp=sharing)
 * In the video, I subscribe notifications in Chrome, Firefox, and Edge. Then I 
   send a notification from the OneSignal dashboard. The Chrome notification opens
   PWA properly. Notification from Firefox only opens Firefox browser and nothing
   else (doesn’t even the right URL). The notification won’t appear at all from 
   Edge.
 * My site: cosmicapp.lahjakortti24.fi
    -  This reply was modified 4 years, 10 months ago by [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/).
 *  [brainmangv](https://wordpress.org/support/users/brainmangv/)
 * (@brainmangv)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14703100)
 * I’m also having problems with onesignal notifications, in console i see the follow
   error:
    `Uncaught SyntaxError: Unexpected token '<' pwa-amp-sw.js:1`
 *     ```
       <?php header("Content-Type: application/javascript");?>importScripts('https://dev.fornerialuce.com.br/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js.php');const CACHE_VERSION='1.7.36.21';const BASE_CACHE_FILES=['https://dev.fornerialuce.com.br/wp-content/uploads/2021/07/logo-pwa.png','https://dev.fornerialuce.com.br/wp-content/uploads/2021/03/cropped-cropped-LOGO-FORNERIA-LUCE-FINAL-EDITION.png',];const OFFLINE_CACHE_FILES=['https://dev.fornerialuce.com.br/offline/?amp=1',];const NOT_FOUND_CACHE_FILES=['https://dev.fornerialuce.com.br/?amp=1',];const OFFLINE_PAGE='https://dev.fornerialuce.com.br/offline/?amp=1';const NOT_FOUND_PAGE='https://dev.fornerialuce.com.br/?amp=1';const CACHE_VERSIONS={content:'content-v'+CACHE_VERSION,notFound:'404-v'+CACHE_VERSION,offline:'offline-v'+CACHE_VERSION,};const MAX_TTL={'/':3600,html:3600,json:86400,js:86400,css:86400,png:86400,jpg:86400,};const CACHE_STRATEGY={default:'cacheFirst',css_js:'cacheFirst',images:'cacheFirst',fonts:'cacheFirst',};const CACHE_BLACKLIST=[];const neverCacheUrls=[/\/wp-admin/,/\/wp-login/,/preview=true/,/\/cart/,/ajax/,/login/,/https:\/\/dev.fornerialuce.com.br\/carrinho\/https:\/\/dev.fornerialuce.com.br\/https:\/\/dev.fornerialuce.com.br\/?amp/];const SUPPORTED_METHODS=['GET',];function pwaForWpcheckNeverCacheList(url){if(this.match(url)){return false;}
       return true;}
       function pwaForWpisBlackListed(url){return(CACHE_BLACKLIST.length>0)?!CACHE_BLACKLIST.filter((rule)=>{if(typeof rule==='function'){return!rule(url);}else{return false;}}).length:false}
       function pwaForWpgetFileExtension(url){if(typeof url==='string'){let split_two=url.split('?');let split_url=split_two[0];let extension=split_url.split('.').reverse()[0].split('?')[0];return(extension.endsWith('/'))?'/':extension;}else{return null;}}
       function pwaForWpgetTTL(url){if(typeof url==='string'){let extension=pwaForWpgetFileExtension(url);if(typeof MAX_TTL[extension]==='number'){return MAX_TTL[extension];}else{return MAX_TTL["/"];}}else{return MAX_TTL["/"];}}
       function pwaForWpinstallServiceWorker(){return Promise.all([caches.open(CACHE_VERSIONS.content).then((cache)=>{if(BASE_CACHE_FILES.length>0){for(var i=0;i<BASE_CACHE_FILES.length;i++){pwaForWpprecacheUrl(BASE_CACHE_FILES[i])}}}),caches.open(CACHE_VERSIONS.offline).then((cache)=>{return cache.addAll(OFFLINE_CACHE_FILES);}),caches.open(CACHE_VERSIONS.notFound).then((cache)=>{return cache.addAll(NOT_FOUND_CACHE_FILES);})]).then(()=>{return self.skipWaiting();});}
       function pwaForWpcleanupLegacyCache(){let currentCaches=Object.keys(CACHE_VERSIONS).map((key)=>{return CACHE_VERSIONS[key];});return new Promise((resolve,reject)=>{caches.keys().then((keys)=>{return legacyKeys=keys.filter((key)=>{return!~currentCaches.indexOf(key);});}).then((legacy)=>{if(legacy.length){Promise.all(legacy.map((legacyKey)=>{return caches.delete(legacyKey)})).then(()=>{resolve()}).catch((err)=>{reject(err);});}else{resolve();}}).catch(()=>{reject();});});}
       function pwaForWpprecacheUrl(url){if(!pwaForWpisBlackListed(url)){caches.open(CACHE_VERSIONS.content).then((cache)=>{cache.match(url).then((response)=>{if(!response){return fetch(url)}else{return null}}).then((response)=>{if(response){fetch(url).then(dataWrappedByPromise=>dataWrappedByPromise.text()).then(data=>{if(data){const regex=/<amp-img[^>]+src="(https:\/\/[^">]+)"/g;let m;while((m=regex.exec(data))!==null){if(m.index===regex.lastIndex){regex.lastIndex++;}
       m.forEach((match,groupIndex)=>{if(groupIndex==1){if(new URL(match).origin==location.origin){fetch(match).then((imagedata)=>{cache.put(match,imagedata.clone());});}}});}}});return cache.put(url,response.clone());}else{return null;}});})}}
       var fetchRengeData=function(event){var pos=Number(/^bytes\=(\d+)\-$/g.exec(event.request.headers.get('range'))[1]);console.log('Range request for',event.request.url,', starting position:',pos);event.respondWith(caches.open(CACHE_VERSIONS.content).then(function(cache){return cache.match(event.request.url);}).then(function(res){if(!res){return fetch(event.request).then(res=>{return res.arrayBuffer();});}
       return res.arrayBuffer();}).then(function(ab){return new Response(ab.slice(pos),{status:206,statusText:'Partial Content',headers:[['Content-Range','bytes '+pos+'-'+
       (ab.byteLength-1)+'/'+ab.byteLength]]});}));}
       let cachingStrategy={notGetMethods:function(event){if(event.request.method!=='GET'){event.respondWith(fetch(event.request).catch(error=>{return caches.match(offlinePage);}));return false;}},fetchFromCache:function(event){return caches.open(CACHE_VERSIONS.content).then((cache)=>{return cache.match(event.request).then((response)=>{if(response){let headers=response.headers.entries();let date=null;for(let pair of headers){if(pair[0]==='date'){date=new Date(pair[1]);}}
       if(date){let age=parseInt((new Date().getTime()-date.getTime())/1000);let ttl=pwaForWpgetTTL(event.request.url);if(age>ttl){return new Promise((resolve)=>{return fetch(event.request.clone()).then((updatedResponse)=>{if(updatedResponse){cache.put(event.request,updatedResponse.clone());resolve(updatedResponse);}else{resolve(response)}}).catch(()=>{resolve(response);});}).catch((err)=>{return response;});}else{return response;}}else{return response;}}else{return null;}}).then((response)=>{if(response){return response;}else{return fetch(event.request.clone()).then((response)=>{if(response.status<300){if(~SUPPORTED_METHODS.indexOf(event.request.method)&&!pwaForWpisBlackListed(event.request.url)){cache.put(event.request,response.clone());}
       return response;}else{return caches.open(CACHE_VERSIONS.notFound).then((cache)=>{return cache.match(NOT_FOUND_PAGE);})}}).then((response)=>{if(response){return response;}}).catch(()=>{return caches.open(CACHE_VERSIONS.offline).then((offlineCache)=>{return offlineCache.match(OFFLINE_PAGE)})});}}).catch((error)=>{console.error('  Error in fetch handler:',error);throw error;});})},fetchnetwork:function(event){return caches.open(CACHE_VERSIONS.content).then((cache)=>{return fetch(event.request.clone()).then(function(response){if(response.status<300){if(~SUPPORTED_METHODS.indexOf(event.request.method)&&!pwaForWpisBlackListed(event.request.url)){cache.put(event.request,response.clone());}
       return response;}else if(response.status==404){return cachingStrategy.Notfoundpage();}else if(cache.match(event.request)){return cache.match(event.request);}else{return cachingStrategy.Offlinepage();}}).catch((err)=>{return cache.match(event.request)}).catch((err)=>{return cachingStrategy.Offlinepage();})}).catch((err)=>{return cachingStrategy.Offlinepage();})},addCache:function(event,updatedResponse){cache.put(event.request,updatedResponse.clone());resolve(updatedResponse);},Offlinepage:function(){return caches.open(CACHE_VERSIONS.offline).then((cache)=>{return cache.match(OFFLINE_PAGE);})},Notfoundpage:function(){return caches.open(CACHE_VERSIONS.notFound).then((cache)=>{return cache.match(NOT_FOUND_PAGE);})},networkOnlyStrategy:function(event){return caches.open(CACHE_VERSIONS.content).then((cache)=>{return fetch(event.request.clone()).then(function(response){if(response.status<300){if(~SUPPORTED_METHODS.indexOf(event.request.method)&&!pwaForWpisBlackListed(event.request.url)){cache.put(event.request,response.clone());}
       return response;}else if(response.status==404){return cachingStrategy.Notfoundpage();}else if(cache.match(event.request)){return cache.match(event.request)}else{return cachingStrategy.Offlinepage();}}).catch((err)=>{return cachingStrategy.Offlinepage();})}).catch((err)=>{return cachingStrategy.Offlinepage()});},cacheFirstStrategy:function(events){return cachingStrategy.fetchFromCache(events).catch((err)=>{return cachingStrategy.Offlinepage()});},NeworkFirstStrategy:function(events){return cachingStrategy.fetchnetwork(events).catch((err)=>{return cachingStrategy.fetchFromCache(events)}).catch((err)=>{return cachingStrategy.Offlinepage()});}}
       self.addEventListener('install',event=>{event.waitUntil(Promise.all([pwaForWpinstallServiceWorker(),self.skipWaiting(),]));});self.addEventListener('activate',event=>{event.waitUntil(Promise.all([pwaForWpcleanupLegacyCache(),self.clients.claim(),self.skipWaiting(),]).catch((err)=>{self.skipWaiting();}));});self.addEventListener('online',event=>{if(navigator.onLine&&navigator.standalone===true){isReachable(event.request.url).then(function(online){if(online){caches.delete(event.request.url);console.log('online');}else{console.log('no connectivity');}});}else{console.log('offline');}});function isReachable(url){return fetch(url,{method:'HEAD',mode:'no-cors'}).then(function(resp){return resp&&(resp.ok||resp.type==='opaque');}).catch(function(err){console.warn('[conn test failure]:',err);});}
       self.addEventListener('fetch',event=>{if(!neverCacheUrls.every(pwaForWpcheckNeverCacheList,event.request.url)){return;}
       if(!neverCacheUrls.every(pwaForWpcheckNeverCacheList,event.request.referrer)){return;}
       if(pwaForWpisBlackListed(event.request.url)){return;}
       if(!event.request.url.match(/^(http|https):\/\//i))
       return;if(event.request.referrer.match(/^(wp-admin):\/\//i))
       return;if(new URL(event.request.url).origin!==location.origin)
       return;if(event.request.headers.get('range')){fetchRengeData(event);}else{if(event.request.method!=='GET'){event.respondWith(fetch(event.request).catch(error=>{return caches.open(CACHE_VERSIONS.offline).then(function(cache){return cache.match(OFFLINE_URL);});}));return false;}
       const destination=event.request.destination;switch(destination){case 'style':case 'script':cachingStrategyType=CACHE_STRATEGY.css_js;break;case 'document':cachingStrategyType=CACHE_STRATEGY.default
       break;case 'image':cachingStrategyType=CACHE_STRATEGY.images;break;case 'font':cachingStrategyType=CACHE_STRATEGY.fonts;break;default:cachingStrategyType=CACHE_STRATEGY.default}
       var cache=null;switch(cachingStrategyType){case "networkFirst":cache=cachingStrategy.NeworkFirstStrategy(event)
       break;case "networkOnly":cache=cachingStrategy.networkOnlyStrategy(event)
       break;case "cacheFirst":case "staleWhileRevalidate":default:cache=cachingStrategy.cacheFirstStrategy(event)
       break;}
       event.respondWith(cache);}});self.addEventListener('message',(event)=>{if(typeof event.data==='object'&&typeof event.data.action==='string'){switch(event.data.action){case 'cache':pwaForWpprecacheUrl(event.data.url);break;default:console.log('Unknown action: '+event.data.action);break;}}});
       ```
   
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14705991)
 * Thanks for sharing the video. We will look into it and get back to you shortly.
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14705997)
 * brainmangv: As per forum guidelines, Please create a new topic.
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14723949)
 * Any updates?
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14728939)
 * It seems you didn’t install PWA on your mobile but add the website to the screen.
   And also can you please let me know, how you have added those icons on your home
   screen?
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14730989)
 * I have installed the PWAs. Every time I open PWAs I got a notification that is
   related to PWA.
    Check these: [https://photos.app.goo.gl/QM8VRC6pC3LezY658](https://photos.app.goo.gl/QM8VRC6pC3LezY658)
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14738800)
 * We will look into this and get back to you shortly.
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14773740)
 * Any updates here?
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14799464)
 * As we can check here onesignal settings have not proper serviceworker name, please
   check is there any update available or ebable the compatibility option.
 * Reference screengrab: [https://prnt.sc/1qgu55o](https://prnt.sc/1qgu55o)
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14813728)
 * I already have enabled compatibility option:
    [https://prnt.sc/1qnw6h8](https://prnt.sc/1qnw6h8)
 * What is proper service worker name?
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14831436)
 * It will automatically come. no need to do anything. Can you please let us know,
   are you using the old one signal? Because in the new one signal there is the 
   file name is different.
 *  Thread Starter [Juuso Turunen](https://wordpress.org/support/users/juusoturunen/)
 * (@juusoturunen)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14832123)
 * I have version 2.2.2
 * I checked this OneSignal documentation and I didn’t get what file name is wrong.
   
   [https://documentation.onesignal.com/docs/onesignal-service-worker-faq](https://documentation.onesignal.com/docs/onesignal-service-worker-faq)
 *  Plugin Author [Magazine3](https://wordpress.org/support/users/magazine3/)
 * (@magazine3)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14865791)
 * Sorry for the delay in getting back extremely. As we checked in one signal setting,
   it does not have a proper service-worker name, You can see it in the following
   screengrab: [https://prnt.sc/1qgu55o](https://prnt.sc/1qgu55o).

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Notifications problem’ is closed to new replies.

 * ![](https://ps.w.org/pwa-for-wp/assets/icon-256x256.png?rev=1939317)
 * [PWA for WP - Progressive Web Apps Made Simple](https://wordpress.org/plugins/pwa-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pwa-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pwa-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/pwa-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pwa-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pwa-for-wp/reviews/)

 * 15 replies
 * 3 participants
 * Last reply from: [Magazine3](https://wordpress.org/support/users/magazine3/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/notifications-problem/#post-14865791)
 * Status: not resolved