I am trying to create web notifications like those used by facebook when we receive a message, and create the notification, but how can I send it every time I detect a new record in my database?
my notification is the following
<script src="https://pushjs.org/scripts/push.min.js" ></script>
<script>
Push.create("Tienes un nuevo ticket", {
body: "$funcionario tiene una incidendi",
icon: '/icon.png',
timeout: 4000,
onClick: function () {
window.focus();
this.close();
}
});
</script>
</div>
I don't think your can trigger a function in PHP when database is updated (Unless you can access a function where it is updating database).
You can write a CRON function/Poll function to check the database every few seconds and trigger the notification when you see the change.
there is 2 solution using cron job or using nodejs
search in google about cronjob