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.
Modifying the notification click event - JavaScript Tutorial
From the course: JavaScript: Progressive Web Applications
Modifying the notification click event
- [Instructor] At this point, our notificationClick event will navigate to the loc property of the payload supply, but only if the app is open and visible. This means that the user must be currently looking at the app for the navigation to work. Since we can't rely on the app being in focus, and the intent of push messaging is to re-engage the user, we need to implement behavior that will wake the app if it's not currently active. To do this, we need to modify the notificationClick event handler. So let's scroll up and find the notificationClick event handler, and here's what we'll do. Just after we get the collection of all clients, I'm going to add a variable. So find where we've logged all the clients to the console, and hit ENTER. Let's create a variable called matchingClient. And I'm going to initialize that to be null. Then, as we loop through all of the clients available, if we find one that's visible, we'll assign that client to the matching client. So, just before the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to notifications2m 21s
-
(Locked)
Requesting permission to show notifications5m 26s
-
(Locked)
Displaying a notification4m 50s
-
(Locked)
Adding data to a notification4m 36s
-
(Locked)
Closing a notification3m 33s
-
(Locked)
Handling the notification click event11m 25s
-
(Locked)
Push messaging overview1m 24s
-
(Locked)
Adding Firebase Cloud Messaging to the project2m 15s
-
(Locked)
Subscribing to push messaging6m
-
(Locked)
Handling push notifications3m 14s
-
(Locked)
Sending a tickle using cURL4m 57s
-
(Locked)
Sending data in a push message2m 9s
-
(Locked)
Installing Mozilla's Web Push library2m 51s
-
(Locked)
Modifying the push event handler2m 52s
-
(Locked)
Modifying the notification click event3m 48s
-
(Locked)
Creating the web push script6m
-
(Locked)
Testing the hosted app5m 7s
-
(Locked)
-
-