From the course: JavaScript: Progressive Web Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Push messaging overview

Push messaging overview - JavaScript Tutorial

From the course: JavaScript: Progressive Web Applications

Start my 1-month free trial

Push messaging overview

- [Instructor] The work we've done with notifications has been great, but the chief reason to implement notifications is to reengage users. What we've built so far will only fire a notification when the user runs the PWA, in other words, they're already engaged. What we need is to be able to show notifications to users when the app isn't open. The web push API fits that bill nicely. In general, push notifications work like this, the client accesses the PWA, and it asks the user to allow notifications via the push manager's subscribe method. If the user allows notifications, a subscription object is created. Developers need to store the data in the subscription for sending push messages. An HTTPS Post request, that may or may not originate from the app server, is made to a messaging service that includes data from the subscription. The messaging service sends the push message to the client using data stored in the subscription. If needed, when the message is received, the app is…

Contents