我希望能够像 WhatsApp Web 推送通知或 Telegram Web 通知一样播放音频。我已经能够在服务工作者中接收推送通知,问题在于如何在接收到推送通知时播放音频?
我已经阅读了这里的 Notification API 文档:https://developer.mozilla.org/en-US/docs/Web/API/notification/sound 根据文档,Notification 有参数声音(Notification.sound)。
我已经将该参数实现到我的语法中:
我已经阅读了这里的 Notification API 文档:https://developer.mozilla.org/en-US/docs/Web/API/notification/sound 根据文档,Notification 有参数声音(Notification.sound)。
我已经将该参数实现到我的语法中:
self.registration.showNotification(title, {
body: body,
icon: icon,
tag:tag,
data: data,
sound: 'http://127.0.0.1/myfolder/audio/alert.mp3'
})
但是在Service Worker中收到推送消息后仍然无法播放音频,如何实现播放?
谢谢。