gpt4 book ai didi

javascript - 自定义 Web 推送通知 (Google Chrome)

转载 作者:行者123 更新时间:2023-11-28 01:06:31 43 4
gpt4 key购买 nike

所以我设法使用 Google Project 和 Service Worker 为 Google Chrome 实现了一个网络推送通知。

我的问题是如何自定义或装饰推送通知,因为消息框是普通的。相反,我想用 html 和 css 来装饰它。

 self.addEventListener('push', function(event) {
console.log('Push message received', event);
var title = 'Push message';
event.waitUntil(
self.registration.showNotification(title, {
body: 'Please choose to like or reply
icon: 'images/icon.png',
tag: 'my-tag',
actions:[
{action:"like", title: "Like"},
{action:"reply", title: "⤻ Reply"}]
}));
});

最佳答案

您不能添加 HTML 和 CSS,至少现在不能。你最多只能在标题、描述和操作按钮中使用表情符号和图标,但目前还没有浏览器具有此功能。

关于javascript - 自定义 Web 推送通知 (Google Chrome),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39508435/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com