safwanrahman / django-webpush

Web Push Notification Package for Django
GNU General Public License v3.0
362 stars 103 forks source link

Cannot read properties of undefined (reding 'pushManager') #134

Open NicoCaldo opened 9 months ago

NicoCaldo commented 9 months ago

On Chrome I'm getting an error on line 95 of webpush.js when I try to subscribe with the error

Cannot read properties of undefined (reding 'pushManager')
at subscribe (webpush.js:95:7)
at HTMLButtonElement.<anonymous> (webpush.js:16:14)

I've correctly created the VAPID key like the documentation describe

NicoCaldo commented 9 months ago

Everything works fine if I use localhost but when I try to access my server within the local network using http://my_ip I got the error. Even from localhost but using any localhost IP (0.0.0.0) and/or (127.0.0.1) the error occurs

NicoCaldo commented 9 months ago

It turned out you need your server to run on HTTPS

I have geenrated a self signed certificate on my server matching its IP and loclahost but now the error is

An unknown error occurred when fetching the script.
my_ip/:1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('https://my_ip:8080/webpush/') with script ('https://my_ip:8080/webpush/service-worker.js'): An unknown error occurred when fetching the script.

Now, in Mozilla works correctly, in Chrome i'm having the issue above

NicoCaldo commented 9 months ago

It seems the worker is not loaded in Chrome image

NicoCaldo commented 9 months ago

Could it be chrome doesn't allow self-signed certificate for web workers?