JSPM

@diadal/quasar-app-extension-firebase-messaging

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q44181F
  • License MIT

Sets up FCM service worker for quasar applications

Package Exports

  • @diadal/quasar-app-extension-firebase-messaging
  • @diadal/quasar-app-extension-firebase-messaging/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@diadal/quasar-app-extension-firebase-messaging) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Quasar Firebase Messaging App Extension

Install

yarn add firebase
yarn add @diadal/quasar-app-extension-firebase-messaging
quasar ext invoke @diadal/firebase-messaging

Setup

Create a file named firebase-messaging-sw.js in src/assets with below contents

import { initializeApp } from 'firebase/app';
import { getMessaging, onBackgroundMessage } from 'firebase/messaging/sw';
import { onMessage } from 'firebase/messaging';


const firebaseConfig = {....};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);

onMessage(messaging, (payload) => {
  console.log('Message received. ', payload);
});

onBackgroundMessage(messaging, (payload) => {
  console.log(
    '[firebase-messaging-sw.js] Received background message ',
    payload
  );
  const notificationTitle = 'Background Message Title';
  const notificationOptions = {
    body: 'Background Message body.',
    icon: '/icons/favicon-32x32.png',
  };
  self.registration.showNotification(notificationTitle, notificationOptions);
});