Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension development: auto close the notification box

After doing something I run this code:

var notification = webkitNotifications.createNotification(
   'icon.png',  // icon url - can be relative
  'Done!',  // notification title
  'Just updated your list!'  // notification body text
   );
  notification.show();

which of course pops up a notification into the users screen.

It there anyway to time this notification so that it auto-closes in X amount of seconds?

Thanks! R

like image 987
Ryan Avatar asked Apr 20 '11 14:04

Ryan


2 Answers

You can use notification.cancel();

like image 50
qiufangzhou Avatar answered Nov 12 '22 01:11

qiufangzhou


var notification = webkitNotifications.createNotification('images/icon-48x48.png',"This is       Title","Biswarup Adhikari Notification");
notification.show();
setTimeout(function(){
notification.cancel();
},2000);

Chrome notification will close automatically after 2000 milli sec or 2 sec.

like image 33
biswarupadhikari Avatar answered Nov 12 '22 02:11

biswarupadhikari