+ 1

Can someone please explain the below code for me

if ('serviceWorker' in navigator && 'PushManager' in window) {   console.log('Service Worker and Push is supported');   navigator.serviceWorker.register('sw.js')   .then(function(swReg) {     console.log('Service Worker is registered', swReg);     swRegistration = swReg;   })   .catch(function(error) {     console.error('Service Worker Error', error);   }); } else {   console.warn('Push messaging is not supported');   pushButton.textContent = 'Push Not Supported'; }

1st Oct 2020, 1:28 PM
Evans Frimpong
Evans Frimpong - avatar
1 ответ
0
it is a code to verify if push notifications are working properly, and it saves into log / console to show debugging
2nd Oct 2020, 5:45 PM
Joseph Lazarus
Joseph Lazarus - avatar