I have a code, which I want to make a live push notification system, here's my code:
<script>
Notification.requestPermission();
function requisitar(){
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
var text=xmlhttp.responseText;
if (xmlhttp.readyState==4 && xmlhttp.status==20)
{
var notification = new Notification("Site DaviDEV", {
icon: 'http://i.imgur.com/cWk851f.png',
body: text
});
notification.onclick = function() {
window.open("<?php echo $url; ?>");
}
}
}
xmlhttp.open("GET","/notificacao/notificacao.txt",true);
xmlhttp.send();
}
window.setInterval(requisitar, 1000);
</script>
More he can read the file and send the notification, but there is a problem: He sends several notifications, like a spam, I want something that is sent to each person, what can I do?