在通知中包含图像

Include image in notification

我目前正在尝试将 Chrome 扩展程序转换为 Firefox。原始 Chrome 扩展涉及 "image" 类型的通知。代码如下:

chrome.notifications.create({
    type: "image",
    iconUrl: "image/logo.jpg",
    imageUrl: "image/testimage.jpg",
    title: "Test",
    message: "Test message"
 });

现在,当通过将 chrome. 更改为 browser. 将此通知转换为 Firefox 时,通知会很好地弹出 - 尽管没有图像。从 MDN 站点上,我得到一个模糊的印象,即此功能(尚未)包含在 Firefox 通知中 API。谁能告诉我是否是这种情况(如果是,该功能是否会很快实施)?还是我做错了什么?还有其他方法可以在 Firefox 中实现图像通知吗?

唯一的type of notification that Firefox supports is the 'basic' type. For an image, the 'basic' type supports an optional iconUrl.

当其他类型的 Notifications will be implemented in Firefox is unclear. Until something is actually in the process of being implemented, or at least further in the process than it is currently, there is no good way to tell exactly when it will happen. Although, filing a bug requesting the functionality 发生时更容易追踪。

And is there any other way to implement image notifications in Firefox?

官方说法,没有。如果你真的想要,你可以在你的扩展中打开一个 window windows.create() 到一个 URL 来显示所需的图像。

你可以做些什么来让它更快发生

不需要从 chrome.* 更改为 browser.*

您无需将 API 调用从 chrome.* 更改为 browser.* 即可在 Firefox 中运行。所有 WebExtension API 都可以作为 chrome.* and browser.*. The chrome.* namespace works with callbacks, just as it does in Chrome (with minor, mostly documented incompatibilities, as listed on each JavaScript API page). The browser.* namespace works with Promises.