ludei / atomic-plugins-notifications

2 stars 2 forks source link

Not registering for notifications #1

Open fabstao opened 8 years ago

fabstao commented 8 years ago

Hi!

This is my code:

        Cocoon.Notification.Local.initialize({}, function(registered) {
            if (!registered) {
                alert('Notificaciones deshabilitadas por el usuario');
                Cocoon.Notification.Local.register();
            }
            else {
                //sendNotification(); 
            }
        });
mandaNotificacion("No circula:","Mañana no circula la placa "+$('#placas').val());

I receive a not registered error and notifications are not working,

please help 😁

nikoladev commented 8 years ago

There's a bug in line 130 of cocoon_notifications.js that ensures that registered is always false: https://github.com/ludei/atomic-plugins-notifications/blob/master/src/js/cocoon_notifications.js#L130

This is a workaround that should fix it for now:

Cocoon.Notification.Local.initialize({}, function (registered) {
    Cocoon.Notification.Local.isRegistered(function (granted) {
        if (!granted) {
            alert('Notificaciones deshabilitadas por el usuario');
        } else {
            //sendNotification();
        }
    });
});