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,506
  • 13
  • 48
  • 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,123
  • 3
  • 33
  • 31
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
  • 109,619
  • 77
  • 317
  • 330
1

for me this worked

setTimeout(function() {
    notification.close();
}, 2000);
h0mayun
  • 3,466
  • 31
  • 40