+ 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