 Hello and welcome to the second episode of... Huh? That was weird. Well, hello and welcome... Hi, I'm Tom. And in today's episode of Why Build Progressive Web Apps, I want to talk to you about push notifications and how and why you would want them. Let's face it. On the web, push notifications have become a bit of an omnipresent annoyance. The reason for the bad reputation of push notifications, in my opinion, is that we have been, well, a little bit too pushy in trying to get people to allow them. The folks over at Mozilla have raised it like this in a blog post. Online, your attention is priceless. That's why every site in the universe wants permission to send you notifications about new stuff. It can be distracting at best and annoying at worst. A particularly bad practice is to pop up the permission dialogue on page load without any context at all. Several high traffic sites have been caught doing this. To subscribe people to push notifications, you use the PushnoManager interface. Now to be fair, this does not allow you to specify the context or the to be expected frequency of notifications. So where does this leave us? First, maybe let's take one step back and brainstorm why we would want push notifications in the first place. If done right, push notifications are actually pretty great. For example, they can inform you if you have been outbid on an auction site. They can alert you about severe weather conditions in your hometown. On a less serious note, they can notify you when you have a match on a dating site. Or they can let you know if there's a significant price drop for something you're interested in. And yes, of course, push notifications can also inform you of new content on a use site. As I said some moments ago, there's no way on the API level to inform users about the context of push notifications. All you can do with the options parameter is set a flag whether the notifications should be user visible or silent and provide the application server key. In consequence, it's crucial that we as application developers provide the context for our notifications ourselves. Maybe you remember the AffiliCAD sample app from the last episode, a simple app that simulates a comparison site where you can get great deals for cats. What's new this time is a button for getting price drop alerts. When you press it for the very first time, the notification permissions dialog pops up and it's immediately clear that it's connected to you clicking the price drop alerts button. If you grant permission, the app subscribes us to a push notification endpoint that is configured to send out dummy notifications five seconds after signing up. And five, four, three, two, one, and boom. So you can see prices for cats are dropping. We better get one while they're last. And there we have it, an actually useful push notification. It was contextual, meaningful, and timely. The AffiliCAD app is open source. Go check out the code if you want to see how it's implemented. Push notifications are a great power, and with great power comes great responsibility. If you remember just one thing from this video, I hope its context matters. In the next episode of Why Build Progressive Web Apps, look at another PWA superpower, add to home screen, looking forward to seeing you.