Last active
April 13, 2019 16:20
-
-
Save Eder87rh/a090f6e3888688357fc08b4e6f2c0e43 to your computer and use it in GitHub Desktop.
5 - cropchien - firebase-messaging-sw.js
This file contains hidden or 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
| importScripts('https://www.gstatic.com/firebasejs/5.6.0/firebase-app.js'); | |
| importScripts('https://www.gstatic.com/firebasejs/5.6.0/firebase-messaging.js'); | |
| self.__precacheManifest = [].concat(self.__precacheManifest || []); | |
| workbox.precaching.suppressWarnings(); | |
| workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); | |
| workbox.routing.registerRoute( | |
| new RegExp('https://firebasestorage.googleapis.com/v0/b/cropchien.appspot.com/.*'), | |
| workbox.strategies.staleWhileRevalidate() | |
| ); | |
| firebase.initializeApp({ | |
| 'messagingSenderId': 'PASTE_YOUR_SENDER_ID_HERE' | |
| }); | |
| const messaging = firebase.messaging(); | |
| messaging.setBackgroundMessageHandler(function(payload) { | |
| console.log('[firebase-messaging-sw.js] Received background message ', payload); | |
| // Customize notification here | |
| const notificationTitle = 'Background Message Title'; | |
| const notificationOptions = { | |
| body: 'Background Message body.', | |
| icon: '/firebase-logo.png' | |
| }; | |
| return self.registration.showNotification(notificationTitle, | |
| notificationOptions); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment