感謝IO團隊..我們需要檢查當前的服務人員是否變得冗餘
// Check to see if the service worker controlling the page at initial load
// has become redundant, since this implies there's a new service worker with fresh content.
if (navigator.serviceWorker && navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.onstatechange = function(event) {
if (event.target.state === 'redundant') {
// Define a handler that will be used for the next io-toast tap, at which point it
// be automatically removed.
const tapHandler = function() {
window.location.reload();
};
if (IOWA.Elements && IOWA.Elements.Toast &&
IOWA.Elements.Toast.showMessage) {
IOWA.Elements.Toast.showMessage(
'A new version of this app is available.', tapHandler, 'Refresh',
null, 0); // duration 0 indications shows the toast indefinitely.
} else {
tapHandler(); // Force reload if user never was shown the toast.
}
}
};
}
Web的應用程序的支持[推送通知(https://developers.google.com/網絡/基礎/工具入門/ codelabs /推通知/)。但這似乎是錯誤的通知用戶該應用程序已更新。你爲什麼要用戶「重啓瀏覽器」?服務工作人員會在檢測到任何更改時自動執行此操作... – alesc
我看到並理解的是,服務工作人員不重新啓動應用程序,只是在緩存下載完成時更新自身和緩存,必須重新啓動在緩存中獲取新應用程序的應用程序...我只記得Eric在談論這個話題的時候,我會試着去找這個話題。 – eskan