Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
NW.js Essentials

You're reading from   NW.js Essentials Build native desktop applications for Windows, Mac OS, or Linux using the latest web technologies

Arrow left icon
Product type Paperback
Published in May 2015
Publisher
ISBN-13 9781785280863
Length 192 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
 Benoit Benoit
Author Profile Icon Benoit
Benoit
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

NW.js Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Meet NW.js FREE CHAPTER 2. NW.js Native UI APIs 3. Leveraging the Power of Node.js 4. Data Persistence Solutions and Other Browser Web APIs 5. Let's Put It All Together 6. Packaging Your Application for Distribution 7. Automated Packaging Tools 8. Let's Debug Your Application 9. Taking Your Application to the Next Level Index

The Web Notifications API


Notifications are small popups that are usually shown in the top-right corner of the screen that the operating system implements in order to share important events with the user. Each notification features a title, some descriptive text, and, optionally, a small thumbnail/icon; more notifications can be stacked.

I was really tempted to insert this argument in the Native UI APIs chapter as it shares the same goals, but Notifications APIs, although relatively young, are actually part of HTML5 specifications.

The code to implement web notifications inside your NW.js application is pretty straightforward:

var notification = new Notification('Notification Title', {
  icon: "icon32.png",
  body: "Here is the notification text"
});
notification.onclick = function () {
  console.log("Notification clicked");
};
notification.onshow = function () {
  console.log('Show');
  // Close the Notification after 1 second
  setTimeout(function() {notification.close();}, 1000);
};

You can...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images