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.
Implementing the install banner - JavaScript Tutorial
From the course: JavaScript: Progressive Web Applications
Implementing the install banner
- [Instructor] The next thing to do is to handle the before install prompt event. So we'll do that inside main.js. So I'm gonna add this just beneath the Service Worker Registration, and let's create a placeholder for our install event. That's a variable. Remember what will happen is we'll get the install event and then we'll prompt on the install event later after the criteria are met. Okay? And then, let's call window.addEventListener. And the event we want to listen for is beforeinstallprompt, it's all one word, all lowercase. So, beforeinstallprompt, that needs quotes. And our handle will be a function. Which will receive the event object. Okay, punctuation first. All right, so, let's write ourselves a message, we'll do it in the console. Console.log and I'm gonna just wanna see that the Before Install Prompt event fired. Okay, so, the next thing to do is to take the event and store it for later use. We'll do that in the variable we just created. Install event equals the event we…
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)
Registering a service worker6m 25s
-
(Locked)
The install event and caches9m 29s
-
(Locked)
Activating the service worker5m 26s
-
(Locked)
Intercepting requests using Fetch5m 59s
-
(Locked)
Install banner behavior2m 16s
-
(Locked)
Designing the install banner7m 25s
-
(Locked)
Implementing the install banner7m 32s
-
(Locked)
Debugging with Chrome DevTools4m 59s
-
(Locked)
More Chrome DevTools1m 51s
-
(Locked)
Debugging with Safari and the iOS Simulator5m 50s
-
(Locked)
-
-
-
-