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

Implementing the install banner - JavaScript Tutorial

From the course: JavaScript: Progressive Web Applications

Start my 1-month free trial

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…

Contents