Created
December 25, 2018 11:46
-
-
Save patidardhaval/265357e09820c4ce8e65b5ecfddf94c3 to your computer and use it in GitHub Desktop.
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/3.9.0/firebase-app.js'); | |
importScripts('https://www.gstatic.com/firebasejs/3.9.0/firebase-messaging.js'); | |
// Initialize the Firebase app in the service worker by passing in the | |
// messagingSenderId. | |
firebase.initializeApp({ | |
'messagingSenderId': 'YOUR-SENDER-ID' | |
}); | |
// Retrieve an instance of Firebase Messaging so that it can handle background | |
// messages. | |
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: '/itwonders-web-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