10

I am working on a chrome extension for desktop notification.Is there any way by which I can close the desktop notification after a specified time ?

Hector Barbossa
  • 5,330
  • 13
  • 47
  • 70
  • [Chrome supports desktop notifications natively](http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example). – Dan Dascalescu Feb 11 '14 at 05:46

3 Answers3

12

If you have a reference of the notification object, you can use notification.cancel instead:

  setTimeout(function() { 
      notification.cancel(); 
  }, 5000);

References:

Community
  • 1
  • 1
newtonapple
  • 4,083
  • 3
  • 31
  • 30
9

You can close it by running window.close() from notification's javascript (assuming your notification is a separated HTML file). So something like this:

setTimeout(function() {
    window.close();
}, 5000);
serg
  • 106,723
  • 76
  • 306
  • 327
1

for me this worked

setTimeout(function() {
    notification.close();
}, 2000);
h0mayun
  • 3,368
  • 28
  • 39