nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
640 stars 98 forks source link

On Background Message Listener #354

Closed SalvoLunar closed 3 years ago

SalvoLunar commented 3 years ago

Hi,

Is it possible to configure this plugin to listen for messages in the background as explained here https://firebase.google.com/docs/cloud-messaging/js/receive?

messaging.onBackgroundMessage(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'
  };

  self.registration.showNotification(notificationTitle,
    notificationOptions);
});
lupas commented 3 years ago

Hi @SalvoLunar Sure, check out the documentation at https://firebase.nuxtjs.org/service-options/messaging . You can use createServiceWorker to automatically create the service worker for you.