Ryan
Ryan

Reputation: 10049

Javascript (Chrome extension) notification.cancel() is misbehaving

This is my simple function:

            if (req.status == 200)
            {

                var notification = webkitNotifications.createNotification(
                  'icon.png',  // icon url - can be relative
                  'Done!',  // notification title
                  'Just updated and saved the latest blocklist'  
                );
                notification.show();
                new_version_show_window();
                setTimeout( function () {  notification.cancel(); }, 4000);


            }

Basically its an AJAX call, once it downloads the list it shows the notification,
if its a new install or upgrade it calls ´new_version_show_window()´ and then it should close the notification... but it does not, sometimes it does, sometimes it does not :(

Upvotes: 1

Views: 485

Answers (1)

serg
serg

Reputation: 111265

In couldn't make cancel() work properly either. For a workaround I created an html notification with the following javascript:

setTimeout( function () {  window.close(); }, 4000);

Upvotes: 1

Related Questions