Currently, I am looking to integrate FCM (Firebase Cloud Messaging) into my chrome extension. After conducting thorough research, I have discovered that the most efficient way to implement FCM is by utilizing the old API chrome.gcm
. So far, this method has been effective as I am able to successfully obtain an FCM token when the extension loads.
Now, my goal is to pass this token to the popup powered by Vue.js. However, I have encountered difficulties with the following code:
In the background.js file:
// Code snippet not included for brevity
The popup.vue file contains the following code:
// Code snippet not included for brevity
I have observed that the
chrome.runtime.sendMessage({fcmToken: registrationId})
function does not work as intended. Additionally, I am unable to send or receive messages between the popup and background scripts.
How can I establish communication between the Vue.js-powered popup and the background.js script of the extension? Is it advisable to switch to using the Firebase client library for receiving push notifications, or is sticking with GCM sufficient for this purpose?