If you don't understand the theory, then in practice you have nothing worthwhile will come of it.
And quite a good theory here https://developer.mozilla.org/en-US/docs/Web/API/P...
And it contains a reference to a very real example https://github.com/chrisdavidmills/push-api-demo
How this thing is used in practice.
Once you have decided that you are going to send, you need to do a few things.
1. To ask the user for permission to send notifications. This is done through Notification.requestPermission
. If we get confirmation, then go ahead, if not hammered on this business. Here you need to be very careful and do it gently.
2. To create a background processor that will accept push notifications from the server. This is done via a call to navigator.serviceWorker.register
. For example https://github.com/chrisdavidmills/push-api-demo/b...
He subscribes to the channel. The channel is like a chat room.
For the channel, the server is responsible. The server listens to the port the browser connects to the server and stupidly waiting until the server has something to send. The server may periodically send a blank email message to which the client must respond to maintain the connection active. Therefore, the server can be a lot of open the administrator connection.
3. Write a notification server. Nginx has a nice module
. He will serve clients.
I recommend to view https://www.youtube.com/watch?v=5A5Iw9z6z2s