0

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>
  • 3
    Hi, welcome to Stack Overflow. Your question is very broad. You should try to solve the problem yourself and come back here when you have specific challenges that you could use help with. – Ben Nov 09 '17 at 22:17
  • This should help you with your research https://stackoverflow.com/a/1086448/1857971 – dchayka Nov 09 '17 at 22:49

2 Answers2

1

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.

Praveen Alluri
  • 307
  • 2
  • 14
0

there is 2 solution using cron job or using nodejs

search in google about cronjob

milad nazari
  • 339
  • 3
  • 5