Sound does not work in service worker in Chrome desktop push notification Sound does not work in service worker in Chrome desktop push notification google-chrome google-chrome

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


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();


You can try to use the chrome web-extension background_pages.

It will listen to the service worker and play the audioThe simple method for it would be to requesting the URL in the service worker and capture it in the background script using the chrome.webRequest as mentioned in the link

chrome.webRequest.onBeforeRequest.addListener(    callback, filter, opt_extraInfoSpec);

as mentioned in this thread

UpdateAs mentioned in this link

Service Workers require a secure origin, such as HTTPS. chrome-extension:// pages are not HTTP/HTTPS, but are secure so this change becomes a necessary step to allow extensions to register a Service Worker.

"chrome-extension" is added as a scheme allowing service workers.

In the serviceworker script

First you need to register your extension in the manifest.json

  • Request the url in the service worker
  • Capture it in background script using the chrome.webRequest.onBeforeRequest.addListener
  • Play the sound in background.js

and as mentioned by @Alexander currently there is no support for the sound in the MDN