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.

Adding data to a notification

Adding data to a notification - JavaScript Tutorial

From the course: JavaScript: Progressive Web Applications

Start my 1-month free trial

Adding data to a notification

- Let's see if we can show a more complex notification. To do that, let's compose an object literal inside the conditional statement that asks the user for permission to show notifications. Okay, so I'm gonna do that just before we call notify, because we're gonna want to pass this options object into our notify function. So let's create a var that holds our options, set it equal to, and we'll create an options literal. We're gonna include a body property, and that's an extra string to be displayed in a notification, so let's do body, and we'll set that to See What's New. Notice I had to escape out the apostrophe, because I'm using single quotes to encapsulate the string. Again, that beats trying to help me with punctuation and it actually hurts. The next property, let's do an icon property. That's gonna take a URL of an image to display with a notification. I'm gonna use the Android Chrome 192 by 192 file. So let's add an icon property, and that, as a string, is gonna be the path to…

Contents