how to play sound in service worker or even vibrate in chrome?

大城市里の小女人 提交于 2020-06-16 08:11:21

问题


I am using service workers. I need it for push notifications. What I want to achieve is that when I recieve notification, it should play a sound or vibrate at least.

self.registration.showNotification(title, {
   body: body,
   icon: './assets/images/icons/icon_144x144.png',
   vibrate: [200, 100, 200, 100, 200, 100, 200],
});

I am having this piece of code upon receiving a notification.

Problem 1: No vibration happens at all. Then I went ahead of a little bit debugging.

https://googlechrome.github.io/samples/notifications/vibrate.html This DOESN'T vibrate my phone.

https://googlechrome.github.io/samples/vibration/index.html This DOES vibrate my phone.

Why doesn't it vibrate from the first link? I am testing all this on android chrome.

Problem 2: Looks like on firefox, it does have a default sound. Why doesn't google have the same sound? It just goes silent. No way I can play sound ? at least I want to vibrate it...

来源:https://stackoverflow.com/questions/62261805/how-to-play-sound-in-service-worker-or-even-vibrate-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!