Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Is there any way to play custom notification sound in web push notification (Service Worker)?

I've looked many resources and but couldn't found positive results. I want to play some sound while receiving a push notification.

self.addEventListener("push", (e) => {
  const data = e.data.json();
  // console.log("Push Recieved...");
  self.registration.showNotification(data.title, {
    body: data.message,
    icon: data?.icon,
    image: data?.media,
    url: data?.url,
    data: { url: data?.url },
    vibrate: [
      100, 30, 100, 30, 100, 30, 200, 30, 200, 30, 200, 30, 100, 30, 100, 30,
      100,
    ],
  });
  const playSound = new Audio(
    "https://notificationsounds.com/storage/sounds/file-b8_discreet-song.mp3"
  );
  playSound.play();
  alert("NEW ORDER RECEIVED");
  navigator.vibrate([
    100, 30, 100, 30, 100, 30, 200, 30, 200, 30, 200, 30, 100, 30, 100, 30, 100,
  ]);
});

I tried this way also. But caught an error saying Audio is not a function.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!