MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
194 stars 69 forks source link

Getting a token, but not receiving any messages, please help! #73

Closed julianflapper closed 3 years ago

julianflapper commented 3 years ago

Hi,

I am trying to set up my Vue application with Electron and electron-push-receiver.

I am using the following versions:

I my regular Vue app, I can receive notifications from Firebase just fine. It has firebase 7.15.4 installed.

Now, using electron-push-receiver I can get a token (although I have no idea if it is registered with FCM..?), but when trying to receive messages and simply doing console.log for ON_NOTIFICATION_RECEIVE but it's not printing anything nor is it giving any errors.

This is a snippet of my code:

// Display notification
window.ipcRenderer.on(NOTIFICATION_RECEIVED, (_, notification) => {
    console.log('FCM notification received ', notification)
});

The ipcRender is simply attached to the window using a preload.js script:

import { ipcRenderer } from 'electron'
window.ipcRenderer = ipcRenderer

which is properly defined as I succesfully get a token from NOTIFICATION_SERVICE_STARTED event.

How can I find out how to fix this? This functionality is crucial for my app. I really need to receive FCM notifications in Electon. Any help is very much appreciated!

SOLVED:

I am using vue-cli-electorn-builder and turns out I had to set the following options on the electrionBuilder:{} plugin configuration:

externals: ['electron-push-receiver'],
nodeIntegration: true,
codemeall commented 3 years ago

@julianflapper can you please share the ( file / location of file ) where I have to add the above option? getting token but unable to receive message. Thanks