Skip to content

Initialization bug in cocoon_notifications.js #2

@nikoladev

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();
        }
    });
});

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