Push notification in automatic windows

0

Good, I want to send an automatic push notification in windows to all the users that I choose, every time someone makes a record in the database or every time someone executes a function.

I have this code in js that sends a push notification, but I want not only the notification to be sent to the user who executes this script, but also to all the users that I choose.

<script>
    Push.create("Aviso de prueba", {
    body: "Esto es una notificacion de aviso",
    icon: 'img/logo.jpg',
    timeout: 4000,
    onClick: function () {
        window.location="mi_url";
        this.close();
    }
});
    
asked by Tefef 22.01.2018 в 12:23
source

1 answer

0

If you are going to send a message to someone, you should "ask for permission", that is, a window where the user is asked if he wants to receive notifications.

var ver = document.querySelector("#ver");/*Se activa en este caso con un boton*/
ver.addEventListener("click", function(){
        console.log(Notification.permission);
        if(Notification.permission == 'granted'){
            alert("Permiso aceptado");
        }
        else{
            alert("Permiso denegado");
        }
    })
    
answered by 27.06.2018 в 17:52