PHP Classes

Need help getting this working

Recommend this page to a friend!

      PHP Web Push Notifications Server  >  All threads  >  Need help getting this working  >  (Un) Subscribe thread alerts  
Subject:Need help getting this working
Summary:Service worker pnSubscribe never being invoked
Messages:4
Author:Musaffar
Date:2021-06-18 11:49:00
 

  1. Need help getting this working   Reply   Report abuse  
Picture of Musaffar Musaffar - 2021-06-18 11:49:00
Hi

Thanks for the stand alone package.

I am attempting to put together a simple working example and making some progress.

I have configures the various params such as VAPID keys and Subscriber URL and can load PNTestClient.html which I am using to test this.

When I push the the "subscribe PUSH notifications" button, the browser seems to subscribe, however the function pnSubscribe in PNServiceWorker.js never gets called - therefore the subscription never gets saved server side.

Could you point me to anything obvious I may have missed?

Testing on Chrome 91.0.4472.114 Windows 10

Kind Regards
Musaffar

  2. Re: Need help getting this working   Reply   Report abuse  
Picture of Stefan Kientzler Stefan Kientzler - 2021-06-19 11:13:36 - In reply to message 1 from Musaffar
Hi Musaffar,

does the site run in secure context?

Do you have following output from the PNTestClient.html:

Secure context: true
Notification: defined
PushManager: defined
serviceWorker: not defined
Notification.permission: default

What message is shown in the browser console when you click the
[Subscribe PUSH Notifications] Button?

regards, Stefan

  3. Re: Need help getting this working   Reply   Report abuse  
Picture of Manuel Mora Manuel Mora - 2022-04-21 20:02:53 - In reply to message 2 from Stefan Kientzler
Hello Stefan im having the same problem i have my own vapid keys and updated in the js file and php file..

Secure context: true
Notification: defined
PushManager: defined
serviceWorker: defined
Notification.permission: granted

And registration succeeded in console

But the database still no generated and PNTestServer.php send me a blank page.

  4. Re: Need help getting this working   Reply   Report abuse  
Picture of Manuel Mora Manuel Mora - 2022-04-21 21:08:40 - In reply to message 3 from Manuel Mora
I solve that the next issue i have in the console is:

SaveSubscription failed with: SyntaxError: Unexpected end of JSON input
at line: PNServiceWorker.js:53