Prevent chrome.notifications API from hiding my notification after a few seconds

后端 未结 5 2126
说谎
说谎 2020-11-28 11:16

I\'m doing around 1-2 notifications a day and it\'s important the user doesn\'t miss it. Is there a way of removing the auto close and only allowing the user to manually cl

5条回答
  •  忘掉有多难
    2020-11-28 11:51

    UPDATE answar: after Chrome 50, please add new attribute: [requireInteraction: true]!

    don't use chrome.notifications.create

    try to use var notification= new Notification("New mail from John Doe", { tag: 'msg1', requireInteraction: true});
    will not to close.

    if want to close=> notification.close();

    ref: http://www.w3.org/TR/notifications/

    https://developer.mozilla.org/en-US/docs/Web/API/notification/requireInteraction

提交回复
热议问题