+ 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'; }
1 Answer
0
it is a code to verify if push notifications are working properly, and it saves into log / console to show debugging