quasar-app-extension-firebase-messaging-fb9

0.1.2 • Public • Published

Quasar Firebase Messaging App Extension

Install

yarn add firebase
yarn add quasar-app-extension-firebase-messaging
quasar ext invoke firebase-messaging

Setup

Create a file named firebase-messaging-sw.js in src-pwa The package will concatenate the firebase imports at its start

firebase.initializeApp({...});

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);
});

Also, make the entry firebase-messaging-sw.js the entry service worker for your pwa

// replace line
register(process.env.SERVICE_WORKER_FILE, {
--->
// by
register('firebase-messaging-sw.js', {

/quasar-app-extension-firebase-messaging-fb9/

    Package Sidebar

    Install

    npm i quasar-app-extension-firebase-messaging-fb9

    Weekly Downloads

    2

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    4.84 kB

    Total Files

    9

    Last publish

    Collaborators

    • danuzca