MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).

Home Page:https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using FCM in multiple instances of an Electron app

JohannRosenberg opened this issue · comments

I would like to run multiple instances of my app on the same computer. I notice that the sender ID from FCM is the only parameter used to register a client with FCM. This raises the question as to how multiple apps on a computer (even different apps) are able to register separately from other apps. Does your library create some kind of unique ID for the app that it is running on? If not, when a Push message is sent from FCM and multiple apps are running, how does the message get routed to the correct client?

push-receiver does generate an id for each registration here.

In electron-push-receiver, a new registration is created only if we didn't register before or if the credentials have been cleared. See this line.

We could add a way in electron-push-receiver to handle registration & credentials storage in user land.

As electron-push-receiver is just a wrapper around push-receiver, you can also use push-receiver directly and handle registration & credentials storage yourself.

Without looking at your code to figure it out, does this mean that if I run two instances of my app and both are using the same cache folder, both will end up having the same id? I assume that you're storing the id to some file, so when the first app registers, the second app would end up using the same registration id. If that's true, the one solution is to change the user data path for each app instance when the apps start up.

In electron-push-receiver we use electron-config or now electron-store

@MatthieuLemoine
@JohannBlake
Sorry for resurfacing an old post.
I was using the library created by Matthieu, but ran into the problem that: after we built the app, the standalone app on a Mac cannot receive any FCM events, WHILE it can if it's fired up from a terminal or VSCode.
I've been on this problem for a week now - may I ask if you might know what's gone wrong here?
(We have already checked that the token registration worked, and AWS delivered the events to FCM, but we don't know if FCM is somehow misconfigured so the standalone app cannot receive the notification, or maybe the standalone app has some privilege issue.)
Any pointer would be highly appreciated, thank you! 🙏

Not a pointer but, just to let you known that recently I used the lib on Monterey, Catalina and BigSur and it worked fine.. I used AZURE (notification hub) and the App is based on Electron 19.0.0.