How to cause a chrome app to update as soon as possible?

前端 未结 3 1297
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 15:05

Deploying a chrome packaged app and publishing updates on the chrome web store allows users to automatically receive application updates. There are situations where you want

3条回答
  •  伪装坚强ぢ
    2020-12-24 15:37

    Install a listener for chrome.runtime.onUpdateAvailable, which fires when the new .crx file has been downloaded and the new version is ready to be installed. Then, call chrome.runtime.requestUpdateCheck:

    chrome.runtime.onUpdateAvailable.addListener(function(details) {
      console.log("updating to version " + details.version);
      chrome.runtime.reload();
    });
    
    chrome.runtime.requestUpdateCheck(function(status) {
      if (status == "update_available") {
        console.log("update pending...");
      } else if (status == "no_update") {
        console.log("no update found");
      } else if (status == "throttled") {
        console.log("Oops, I'm asking too frequently - I need to back off.");
      }
    });
    

提交回复
热议问题