问题
Trying to understand how this feature works.
MDN article says:
The requireInteraction read-only property of the Notification interface returns a Boolean indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
My test page has this js script:
new Notification("Header text", {
icon: '/images/someImage.png',
body: 'Notification body text!',
requireInteraction : true
});
Tested in different browsers. Windows 10.
- Chrome (56.0.2924.87) - support, no auto-close
- Firefox (53.0a2 dev) - ignores this flag, auto-close after 20 seconds
- Edge (38.14393.0.0) - ignores this flag, auto-close after about 6 seconds, uses windows notifications, and info stay in notification panel
- Opera (43.0.2442.1144) - ignores this flag, auto-close after about 6 seconds, uses windows notifications, info not stay in notification panel
- Yandex browser (17.3.0.1849) support, no auto-close (think it uses chrome inside)
Checked it on android device - notifications stay in notification panel while you don't close them manually.
Some remark about firefox. Here is a bug info about this. It has status:
RESOLVED FIXED in Firefox 52
Checked in both 52 and 53 versions. Results are above. Is this a bug?
And main question: is i am doing it (creating notifications) wrong? Or this is impossible to achieve cross-browser not auto-closing notifications using Notification API?
来源:https://stackoverflow.com/questions/42584952/javascript-notification-api-requireinteraction