JavaScript Notification API requireInteraction

六眼飞鱼酱① 提交于 2020-02-04 05:20:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!