-2

I'm trying to understand how web notification(HTML5) is works.

I found some solutions for call user for permissions:notify.js,

currently I am looking for any way to send notifications for subscribed users. I planing to create a backend script in PHP. What kind of data, should I save when user allows notifications receiving, for easy sending notifications?

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
KarambolNaA4
  • 29
  • 1
  • 5

1 Answers1

2

There are two kinds of web notifications:

  • on-site push notifications: you can send them only when a user has a page of your website open. You can use the Web Notification API (or notify.js) to display the notification. You also need to fetch the notification from a server: you can use AJAX, long polling, websockets, etc.
  • off-site push notifications: you can reach a user even when he is not on your website. You need to use the Web Notification API together with the W3C Push API and service workers. In this case you need to collect an endpoint that represents the user device (browser), then store it on a server and then send notifications to it (for example using this PHP library). Otherwise you can use a service like Pushpad (I am the founder) which offers a PHP library.
collimarco
  • 34,231
  • 36
  • 108
  • 142