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

前端 未结 3 1299
没有蜡笔的小新
没有蜡笔的小新 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:41

    According to the Google Chrome documentation you need to have

    chrome.runtime.onUpdateAvailable.addListener(function(details) {
      chrome.runtime.reload(); // To restart the chrome App instantaneously
    });
    

    But this take time to reflect JS changes into the chrome because background.js loaded into the background and it needs to be unloaded and loaded again

    To cop this situation you need to include

    chrome.runtime.onInstalled.addListener(function(details) {
      chrome.runtime.reload();
    });
    

    as wel.

    onInstalled called whenever google extension installed first time (fresh installation), google extension updated or google chrome updated.

提交回复
热议问题