Chrome Progress Rich Notification Status Won't Move Up
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 d
Solution 1:
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:
var notifyStatus = function(title, message, timeout) {
chrome.notifications.create({
type: 'progress',
iconUrl: 'images/icon128.png',
title: title,
message: message || '',
progress: 0
}, function(id) {
// Automatically close the notification in 4 seconds by defaultvar progress = 0;
var interval = setInterval(function() {
if (++progress <= 100) {
chrome.notifications.update(id, {progress: progress}, function(updated) {
if (!updated) {
// the notification was closedclearInterval(interval);
}
});
} else {
chrome.notifications.clear(id);
clearInterval(interval);
}
}, (timeout || 4000) / 100);
});
};
Post a Comment for "Chrome Progress Rich Notification Status Won't Move Up"