Real-Dev-Squad / notification-service

MIT License
0 stars 1 forks source link

How HTTP push works #2

Closed prakashchoudhary07 closed 1 year ago

Muralidhar22 commented 1 year ago

To implement push notifications in a web application, we need three main components:

A push service:

This is a server-side component that manages the delivery of push notifications to clients. The push service is responsible for sending notifications to the appropriate clients based on their subscription endpoints.

A service worker:

This is a client-side JavaScript file that runs in the background of a web page and handles push notifications sent by the push service. The service worker subscribes to the subscriber endpoint and listens to incoming push notifications, displays them to the user, and may perform additional actions based on the notification payload.

A database:

This is a data storage component that allows you to save and manage subscription endpoints for your users. When a user opts in to receive push notifications, their subscription endpoint is saved to the database. When it's time to send a notification to a particular user,the push service retrieves the user's subscription endpoint from the database and sends the notification to that endpoint.

References:

Web Push API

Some push services that searched for this implementation (need to be researched more on this): Firebase Cloud Messaging (FCM) OneSignal Pusher Amazon Simple Notification Service (SNS) Pushwoosh Airship PushEngage Webpushr Batch PushBots