Last active
December 1, 2020 11:18
-
-
Save m3h0w/7a2f24c61d283379bca5aab313cf9391 to your computer and use it in GitHub Desktop.
Register custom service worker when cra-append-sw operated in dev mode
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 && process.env.NODE_ENV !== 'production') { | |
console.log('Trying to register custom sw'); | |
navigator.serviceWorker | |
.register('./firebase-messaging-sw.js') | |
.then(function (registration) { | |
console.log('Registration successful, scope is:', registration.scope); | |
}) | |
.catch(function (err) { | |
console.log('Service worker registration failed, error:', err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment