Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Iskanje po podpori

Izogibajte se prevarantski tehnični podpori. Nikoli vam ne bomo naročili, da pokličete telefonsko številko ali nam pošljete osebne podatke. Sumljivo dejavnost prijavite z gumbom »Prijavi zlorabo«.

Learn More

Not able to register service worker in mozilla 44

  • 1 odgovor
  • 1 ima to težavo
  • 8 ogledov
  • Zadnji odgovor od philipp

more options

Hi i am trying to implement push notification by the use of service worker. I am able to see push notifications in chrome but i am unable to even register my service worker in mozilla 44.

My code to register my service worker :

if ('serviceWorker' in navigator) {

 console.log('Service Worker is supported');
 navigator.serviceWorker.register('sw.js').then(function() {
   return navigator.serviceWorker.ready;
 }).then(function(reg) {
   console.log('Service Worker is ready :^)', reg);
   reg.pushManager.subscribe().then(function(sub) {
     console.log('endpoint:', sub.endpoint);
     console.log('Subs id',sub.endpoint.substring(sub.endpoint.lastIndexOf('/')+1,sub.endpoint.length));
       subid =  sub.endpoint.substring(sub.endpoint.lastIndexOf('/')+1,sub.endpoint.length);
   });
 }).catch(function(error) {
   console.log('Service Worker error :^(', error);
 });

}

Also, code for service worker push listener :

self.addEventListener('push', function(event) {

 console.log('Push message', event);
 console.log('Check',event.data);
 var title = '123';
 var notification=;

 event.waitUntil(
   self.registration.showNotification(title, {
     'body': '123',
     'icon': 'images/icon.png'
   });

); });

This is working fine in chrome as i am able to see all my messages in console. But in mozilla none of these messages are shown. Please help me with this?

Hi i am trying to implement push notification by the use of service worker. I am able to see push notifications in chrome but i am unable to even register my service worker in mozilla 44. My code to register my service worker : if ('serviceWorker' in navigator) { console.log('Service Worker is supported'); navigator.serviceWorker.register('sw.js').then(function() { return navigator.serviceWorker.ready; }).then(function(reg) { console.log('Service Worker is ready :^)', reg); reg.pushManager.subscribe().then(function(sub) { console.log('endpoint:', sub.endpoint); console.log('Subs id',sub.endpoint.substring(sub.endpoint.lastIndexOf('/')+1,sub.endpoint.length)); subid = sub.endpoint.substring(sub.endpoint.lastIndexOf('/')+1,sub.endpoint.length); }); }).catch(function(error) { console.log('Service Worker error :^(', error); }); } Also, code for service worker push listener : self.addEventListener('push', function(event) { console.log('Push message', event); console.log('Check',event.data); var title = '123'; var notification=''; event.waitUntil( self.registration.showNotification(title, { 'body': '123', 'icon': 'images/icon.png' }); ); }); This is working fine in chrome as i am able to see all my messages in console. But in mozilla none of these messages are shown. Please help me with this?

Vsi odgovori (1)

more options

hi, support.mozilla.org is intended for end-user support. if you have a question regarding web development please refer to Where to go for developer support instead. thank you for your understanding!

https://hacks.mozilla.org/2016/03/debugging-service-workers-and-push-with-firefox-devtools/