Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a closing time for notification extension chrome

I'm developing an extension with chrome.notifications would like to set a time for closing the notification, how can I do this?

like image 345
guto Avatar asked Apr 08 '15 21:04

guto


1 Answers

Chrome automatically hides the notification. How long it stays on screen depends on the priority attribute. Note that everywhere except Chrome OS the hidden notification is effectively closed, as the Notification Center was removed.

It's possible to keep the notification shown, but you'll have to resort to dirty tricks. If you don't want to do it the hard way, consider using Web Notifications instead - they will not be hidden.

Update: Both chrome.notifications and Web Notifications APIs now implement a boolean flag requireInteraction that defines whether Chrome will fade the notification away automatically or not.

You can still manually close (i.e., remove completely) the notification by calling chrome.notifications.clear() with the notification ID.

To schedule something, you can either use DOM intervals, or chrome.alarms API.

like image 148
Xan Avatar answered Sep 21 '22 11:09

Xan