I am currently working on a working service for handling push notifications in a browser. I am currently experiencing a "Registration Registration Error" error. Can anyone help to solve this problem? Check the client1.html and service-worker.js file below:
ERROR:
SW registration error with SecurityError error: Failed to register ServiceWorker: The protocol of the current source URL ("null") is not supported.
service-worker.js
console.log('Started', self); self.addEventListener('install', function(event) { self.skipWaiting(); console.log('Installed', event); }); self.addEventListener('activate', function(event) { console.log('Activated', event); }); self.addEventListener('push', function(event) { console.log('Push message received', event); });
client1.html
<!doctype html> <html> <head> <title>Client 1</title> </head> <body> <script> if('serviceWorker' in navigator){ </script> </body> </html>
source share