How to store Firebase background messages to vuex store in vuejs?

Viewed 210

I'm new to Firebase cloud messaging(FCM). I used web version 9 (modular) FCM in my Vuejs v2 project. I put firebase-messaging-sw.js file on root of my project.
firebase-messaging-sw.js:

importScripts('https://www.gstatic.com/firebasejs/9.0.1/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/9.0.1/firebase-messaging-compat.js');

var firebaseConfig = {
    ...
};

firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();

messaging.onBackgroundMessage(function(payload) {
    //Save payload to vuex store
});

When i want to import store from store package(import {store} from './store/store'), an error raised:
Uncaught SyntaxError: Cannot use import statement outside a module
How can i store FCM messages to vuex store?

0 Answers
Related