Google's Firebase Cloud Messaging (FCM) does not work with decentralized networks. According to its logic, there should be only one account on FCM, which is hardwired into the application, and the server should sign messages with the private key of this account. Naturally, this cuts off the possibility of different people installing several servers interacting with one application, because the private key is to be published, and spam will pour into the application.
Therefore, I had to create a relay (fcm.moera.org
) that forwards messages from different nodes to FCM. When a user enters the application for the first time being logged in, the application forwards the client's FCM ID to its home node, which sends it to the FCM relay. Knowing this identifier confirms that the node has the right to send notifications to the client.
The code in the FCM relay that generates the notification text is shared with the client, that's why I've written the relay also in TypeScript. It's not as terrible as it seems at first glance 😉