问题
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