Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I control how long Chrome App notifications last?

We've got a Chrome app with working notifications, but the notification only lasts a few seconds and then goes away. Our end users are going to want that notification to stay until they dismiss it. Can that be done? We couldn't find anything in the API documentation regarding notification duration.

like image 787
Citizen Avatar asked Aug 19 '14 13:08

Citizen


1 Answers

Update

Since Chrome 50, you can make a notification persist until dismissed with requireInteraction flag:

Indicates that the notification should remain visible on screen until the user activates or dismisses the notification. This defaults to false.

Old answer

You can't make a chrome.notifications notification last forever.

You can sort of control the duration with the priority parameter. From the relevant article (not the main documentation):

Notifications can be assigned a priority between -2 to 2. Priorities < 0 are only shown in the center; priorities > 0 are shown for increasing duration and more high priority notifications can be displayed in the system tray.

Note: if you call update changing the notification's priority, it will be re-shown as needed. You can, in principle, try to exploit that to stay visible.


If you do not need features provided by Rich Notifications, you can use web standard Notification API.

They look similar in Chrome, but do not integrate with the Message Center. As such, they do not disappear unless dismissed by user or programmatically.

like image 74
Xan Avatar answered Oct 12 '22 05:10

Xan