Skip to content

Instantly share code, notes, and snippets.

@zwacky
Last active September 13, 2021 10:11
Show Gist options
  • Save zwacky/dc32dd881ba64357e4e8b93c122db949 to your computer and use it in GitHub Desktop.
Save zwacky/dc32dd881ba64357e4e8b93c122db949 to your computer and use it in GitHub Desktop.
the wrapped service-worker in index.html can then be called if any update is available
// listen to the service worker promise in index.html to see if there has been a new update.
// condition: the service-worker.js needs to have some kind of change - e.g. increment CACHE_VERSION.
window['isUpdateAvailable']
.then(isAvailable => {
if (isAvailable) {
const toast = this.toastCtrl.create({
message: 'New Update available! Reload the webapp to see the latest juicy changes.',
position: 'bottom',
showCloseButton: true,
});
toast.present();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment