Browsers that support web push api to manage user subscriptions and to send notifications to the subscribers. Chrome, Firefox browsers have adapted to service workers to help run services in the background, web push notifications being one of those services. All the leading browsers – Chrome, Firefox, Safari now support web push notifications. While the world is still getting adapted to this powerful communication channel, other browsers are joining the bandwagon, Edge and Opera browsers being the latest additions to this list. And at the same time, we see that the existing browsers – Chrome, Firefox are improving upon their web push methodologies by releasing updates in the latest versions. Browser updates can be overwhelming and website owners often find it difficult to follow the different implementation methodologies set by browsers and keep up with the updates. And hence the website owner would typically turn to third-party service providers such as iZooto to implement web push. It’s an advisable approach, considering the efforts involved in setting this scratch up, however, as a website developer, you should be aware of what goes in the background.
There are two ways through which browsers have exposed web push functionality – - Using service workers, followed by Chrome, Firefox. - The Safari way using push packages.
The Service-Worker Approach
Before we dive deep into the details of web push API, let’s see how the web push operates. It constitutes three important workflows as mentioned below
1. Subscribing to notifications: Whenever a website visitor allows for notifications, the registered service worker creates a unique subscription ID, it’s typically saved by an application server. This subscription ID is used to uniquely identify the user and to send a notification.
2. Sending notification: During this step, the application server connects with and requests push service to deliver notifications to the subscribers. Once this request reaches user’s end-point, service worker takes care of showing a notification to the subscriber.
3. Unsubscribing from notifications: Whenever a subscriber resets the notification permission for a website, the subscription ID is removed from the push server. The application server can also mark the subscription ID for deletion accordingly.