Last active
August 17, 2020 17:18
-
-
Save CoskunKurtuldu/dc892abfb57b301762afd7bacb84badb 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
importScripts('https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js'); | |
importScripts('https://www.gstatic.com/firebasejs/6.0.2/firebase-messaging.js') | |
// Initialize the Firebase app in the service worker by passing in the | |
// messagingSenderId. | |
firebase.initializeApp({ | |
'messagingSenderId': '324534114351' | |
}); | |
// Retrieve an instance of Firebase Messaging so that it can handle background | |
// messages. | |
const messaging = firebase.messaging(); | |
messaging.setBackgroundMessageHandler(function(payload) { | |
let obj = jQuery.parseJSON(payload.data.notification); | |
console.log('[firebase-messaging-sw.js] Received background message ', payload); | |
// Customize notification here | |
const notificationTitle = obj.title; | |
const notificationOptions = { | |
body: obj.body, | |
icon: obj.icon, | |
}; | |
console.log(obj.icon) | |
return self.registration.showNotification(notificationTitle, | |
notificationOptions); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment