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

377
Vistas
How to make a sound when there is an increase in the counter but not a decrease

I am making a call to my firebase database as follows:

//reference from firebase for enquiries
       const Ref = projectDatabase .ref("list").child("enquiries");
            Ref.on("value", (snapshot) => {
  enquiries.value = Object.getOwnPropertyNames(snapshot.val()).length
    });

Everytime a new enquiry comes in (making the length go up by 1) I want to play a sound. But I dont want the sound to play if I delete an enquiry (which makes it go down by 1).

What I tried to implement is :

const sound = ref(new Audio('https://firebasestorage.googleapis.com/v0/b/homejigapp.appspot.com/o/mixkit-positive-notification-951%20(1).wav?alt=media&token=b1452d74-0af3-4da5-b907-c7f94f55d013'));

    //reference from firebase for enquiries
           const Ref = projectDatabase .ref("list").child("enquiries");
                Ref.on("value", (snapshot) => {
      enquiries.value = Object.getOwnPropertyNames(snapshot.val()).length
        sound.value.play();
        });

The issue is that the sound plays every time a user gets on the screen and even when the user rejects an enquiry (so the enquiry length goes down by 1).

Is there a way to make the sound play like an inbox alert (only when a new enquiry comes into the database). A cloud function maybe?

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