Sound does not work in service worker in Chrome desktop push notification

audio, google-chrome, javascript, push-notification, service-worker

Solution

or you can declare myAudio object globally and use play() funcation after or before notification is popped.

myAudio = new Audio("alert_tone.mp3");

var notification = new Notification("Hi there", options);
myAudio.play();

Problem

I'm trying to play sound in push notification in Chrome browser when I get notification. And I have already set the browser push notification on my site but it does not play sound. I'm already going through the option for sound but get no sound. ``` option = { 'body' : 'This is tst Description', 'icon' : 'icon.png', 'silent' : 'false', 'sound' : 'bell.mp3' } ``` If there is any other way to play the sound in the notification, please let me know.

Original source

Related problems