I tried making a Chrome progress Rich Notification but the status bar won't move.
I would think this code would work. The status bar will go up by 1% every 40ms. The notification disappears after 4 seconds (happens to be 100% too). I think there is something wrong with my setInterval
var notifyStatus = function(title, message) {
var k = 0;
chrome.notifications.create('', {
'type': 'progress',
'iconUrl': 'images/icon128.png',
'title': title,
'message': message || '',
'progress': setInterval(function() {
if (k>100) {k;}
else {k++;}
},40)
}, function(nid) {
// Automatically close the notification in 4 seconds.
window.setTimeout(function() {
chrome.notifications.clear(nid);
}, 4000);
});
};
Currently you're assigning
progress
to whatever value setInterval returns just once.You need to update the notification each 40ms with the new progress value using chrome.notifications.update: