PWA Notifications Example: How I finally got it to work!
PWA’s are getting closer and closer to full functionality — but the documentation of them is, in my experience, poor. Let’s help.
________________________________________________________
Reminder: What is a PWA?
If you don’t know what a PWA is, read this or more simply, they are apps that are not delivered via app stores. They are tiny in file size, much faster, quicker to develop, have offline capabilities and even payment capabilities!
________________________________________________________
Overview:
Chrome, Edge and Firefox (and a few others) all support notifications. This is the flow that we need to go through:
- User needs to tell their browser that they want/allow notifications from your website (via a prompt)
- When we are granted permission, we need to get the user’s browser subscription details (these are the identifiers we need to be able to message them)
- We need to save this subscription data to be able to send notifications when we want to
- Later, we need to send the notification and the users subscription details to the browsers…