Skip to content

Instantly share code, notes, and snippets.

@AyoAlfonso
Created December 4, 2018 15:59
Show Gist options
  • Save AyoAlfonso/ac9d6c04e097c43c95fb3bb58f42c5f4 to your computer and use it in GitHub Desktop.
Save AyoAlfonso/ac9d6c04e097c43c95fb3bb58f42c5f4 to your computer and use it in GitHub Desktop.
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');
import messaging from 'config/firebase'
messaging.setBackgroundMessageHandler(function (payload) {
console.log('We Received a background message ', payload);
const notificationTitle = 'New Background Message Title';
const notificationOptions = {
body: 'Fallback Message body.',
icon: 'logo.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
self.addEventListener("notificationclick", function (event) {
const clickedNotification = event.notification;
clickedNotification.close();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment