Can I control how long Chrome App notifications last?

We have a Chrome app with working notifications, but the notification only lasts a few seconds and then leaves. Our end users will want this notice to remain until it rejects it. It can be done? We could not find anything in the API documentation regarding the duration of notifications.

+6
source share
1 answer

Update

Starting with Chrome 50, you can make the notification saved until it is rejected with the requireInteraction flag :

Indicates that the notification should remain visible on the screen until the user activates or rejects the notification. The default value is false.

Old answer

You cannot make the chrome.notifications notification last forever.

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

Notifications can be assigned priority from -2 to 2. Priorities <0 are displayed only in the center; Priorities> 0 are displayed with increasing duration, and notifications with a higher priority can be displayed in the system tray.

Note: if you call update , changing the priority of the notification, it will be re-displayed as necessary. You can, in principle, try to use this to stay visible.


If you don't want the features provided by Rich Notifications, you can use the Notification API web standard.

They are similar in Chrome, but do not integrate with the message center. Thus, they do not disappear unless they are rejected by the user or programmatically.

+11
source

Source: https://habr.com/ru/post/974030/


All Articles