Skip to content

Instantly share code, notes, and snippets.

@ukmadlz
Created May 10, 2017 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukmadlz/c4f7270fa706b4ca12028bdd6e60e78c to your computer and use it in GitHub Desktop.
Save ukmadlz/c4f7270fa706b4ca12028bdd6e60e78c to your computer and use it in GitHub Desktop.
Cloudinary PWA React Blog
// Add Service Worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js', { scope: './' }).then(function(reg) {
if (reg.installing) {
console.log('Service worker installing');
} else if (reg.waiting) {
console.log('Service worker installed');
} else if (reg.active) {
console.log('Service worker active');
}
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment