Chrome.notifications.update does not updated

坚强是说给别人听的谎言 提交于 2020-01-25 06:48:52

问题


In my chrome extension app inside the background script, I am trying to implement this code, here is my code:

function foo(title, message, timeout) {
    chrome.notifications.create({
      type: 'progress',
      iconUrl: 'img/GS icon.png',
      title: title,
      message: message || '',
      progress: 0
    }, function(id) {
      // Automatically close the notification in 4 seconds by default
      var progress = 0;
      var interval = setInterval(function() {
        if (++progress <= 100) {
          chrome.notifications.update(id, {progress: progress}, function(updated) {
            if (!updated) {
              // the notification was closed
              clearInterval(interval);
            }
          });
        } else {
          chrome.notifications.clear(id);
          clearInterval(interval);
        }
      }, (timeout || 4000) / 100);
    });
  };

  window.onload=function(){
    foo('ttttitle','messsageee',10000);
  }

but it always stays on 1% and doesnt move:

can not find the problem.

manifest.json:

{
    "background": {
        "scripts": ["js/background.js"],
        "persistent": false
    },
    ...
}

来源:https://stackoverflow.com/questions/58604309/chrome-notifications-update-does-not-updated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!