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

141
Views
Pushing a browser notification when a threshold is met

I've got the following piece of code (a basic notification that is pushed if the user permits such). My final goal is to have such a notification appear everytime a certain parameter's value reaches a threshold in my project. Let's say I have a live tracker of how many people are in a certain place. If that value passes 50, push a notification. I have not found anything similar and I am unsure where to start from with this.

<script>
        function showNotification() {
          const notification = new Notification("New message form Scenwise", {
            body: "just testing if this notification works"
          })
        }

        if (Notification.permission === "granted") {
          showNotification();
        } 
        else if (Notification.permission !== "denied") {
          Notification.requestPermission().then(permission => {
            if (permission === "granted") {
              showNotification();
            }
          })
        }
</script>
 

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming this parameter is a variable you're maintaining in your javascript and only your code is updating the value of this variable, you should be able implement logic every time you update its value to check if it meets your threshold, and push a notification if necessary.

If you need a more automated solution, this might be helpful to you: Listening for variable changes in JavaScript

about 4 years ago · Juan Pablo Isaza Report
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!