I'm developing an extension with chrome.notifications would like to set a time for closing the notification, how can I do this?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With