Hector Barbossa
Hector Barbossa

Reputation: 5528

Chrome extension Desktop notification

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 ?

Upvotes: 10

Views: 3331

Answers (3)

h0mayun
h0mayun

Reputation: 3621

for me this worked

setTimeout(function() {
    notification.close();
}, 2000);

Upvotes: 1

newtonapple
newtonapple

Reputation: 4133

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

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

References:

Upvotes: 12

serg
serg

Reputation: 111365

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);

Upvotes: 9

Related Questions