Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda