Urgent.News

What's breaking now, across thousands of outlets.

Tech

How Web Push Actually Works: Service Workers, VAPID and FCM in Plain Terms

Web push looks simple from the outside. A visitor clicks "Allow", and later a notification appears even though your site is closed. Underneath, there are four moving parts, and once you understand how they fit together, most push bugs become easy to diagnose. This is a developer-friendly walkthrough of the whole flow, with no vendor SDK in the way. The four parts Your site , which asks for…

Web push notifications operate through a four-part system involving your site, a service worker, a push service, and your application server. The process begins with a service worker, a script stored on your site's domain, which is responsible for receiving push messages. After the service worker is registered, permission is requested from the user, ideally after a user gesture and a brief explanation of the notifications they'll receive.

Next, your site generates a VAPID (Voluntary Application Server Identification) key pair to authenticate with the push service. This key pair includes a public key stored on your server and a private key kept secret. When you send a push notification, your server encrypts the message using the subscriber's public key and signs it with your VAPID private key.

The push service, which could be Firebase Cloud Messaging for Chrome, Mozilla's autopush for Firefox, or Apple's service for Safari, then delivers the encrypted message to the user's browser. The browser wakes up the service worker, which shows the notification to the user. The server's responses to the push requests are crucial for debugging; a 201 Created indicates successful delivery, while a 404 or 410 means the subscription is no longer valid and should be deleted.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Game Design Case Study: How Two Switchable Trucks Turn "Stuck" Into a Puzzle (Over the Ridge Hill 4x4)

🚙 Most mobile offroad games run on short tracks. Over the Ridge Hill 4x4, from InGameDev Mobile, takes a different approach, and it's a useful case study in how one mechanic can shape a whole game.

  • Mobile offroad game Over the Ridge Hill 4x4 introduces switchable trucks mechanic.
  • Players can flip stuck truck back onto wheels without restarting.
  • Game features eight vehicles, six unlocked via ads, emphasizing strategic planning.

More from Thursday 29 October →