After permission has been granted, you can trigger a desktop notification pop-up message at any time in your web application. Naturally, the whole point in displaying a desktop notification is to get the user’s attention when your web application is running in the background. This implies some sort of Ajax-like activity that triggers the launch. The Gmail service is a good example of this implementation. Simply leave Gmail running in the background and as new mail arrives, a desktop notification message makes the announcement.

var notifyAPI = window.webkitNotifications;
 if ( typeof notifyAPI == 'object' &&
      notifyAPI.checkPermission() == 0 ) {
   var notifyMessage = notifyAPI.
 createNotification(iconURL, title, ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.