Last active
December 15, 2017 17:32
-
-
Save jgw96/a371575037b605a7f85e0e75eafb7a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('serviceWorker' in navigator && location.protocol !== 'file:') { | |
window.addEventListener('load', function(){ | |
navigator.serviceWorker.register('/sw.js') | |
.then(function(reg) { | |
reg.addEventListener('updatefound', function() { | |
const toast = document.createElement('div'); | |
toast.innerHTML = '<button>Update available</button>'; | |
document.body.appendChild(toast); | |
}) | |
}) | |
.catch(function(err) { console.log('service worker error', err) }); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment