我正在开发Chrome扩展程序,在我的情况下,我想显示通知。 虽然我设置优先级是2,但它只显示20秒然后消失。 你有什么方法可以增加时间显示通知吗?
答案 0 :(得分:0)
与wOxxOm评论一样,我们可以使用 requireInteraction 来增加时间显示通知。
表示在用户激活或取消通知之前,通知应保持在屏幕上可见。默认为false。
示例:
chrome.notifications.create(warningId,
{
iconUrl: chrome.runtime.getURL('images/icon-48.png'),
title: data.word.toUpperCase(),
type: 'basic',
message: "Test message",
buttons: [{ title: 'Close' }],
isClickable: true,
priority: 2,
requireInteraction: true
},
function() {});