safwanrahman / django-webpush

Web Push Notification Package for Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read properties of undefined (reding 'pushManager')

NicoCaldo opened this issue · comments

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

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

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

It seems the worker is not loaded in Chrome
image

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