Skip to content
Advertisement

PHP successful webpush not triggering push event listener in SW

I would like to implement push notifications to a website, but I can’t trigger push event with PHP and web push library, even though it seems that message is sent successfully.

I’ve tried to trigger the event from the console(chrome), and It works.

Service worker:

JavaScript

Php endpoint(push.php):

JavaScript

My javascript:

JavaScript

Service worker is registered successfully, I can ask for user permission and send values from subscription object back to backend, everything goes fine with web push, but event is still not being triggered.

Any help would be appreciated, thanks.

Advertisement

Answer

Problem was that “keys” value of associative array that I’ve passed to Subscription::create had wrong hardcoded values.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement