Skip to content

Initialization bug in cocoon_notifications.js #2

Description

@nikoladev

The callback in this example from the README always sends out the alert that notifications are disabled:

Cocoon.Notification.Local.initialize({}, function(registered) {
    if (!registered) {
        alert('Notifications disabled by user')
    }
    else {
        sendNotification(); 
    }
})

This is because 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

Until that bug is fixed, this is a workaround that should work:

Cocoon.Notification.Local.initialize({}, function (registered) {
    Cocoon.Notification.Local.isRegistered(function (granted) {
        if (!granted) {
            alert('Notifications disabled by user');
        } else {
            sendNotification();
        }
    });
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions