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>