Ad

Get Messaging Tokens From Go Admin Backend When Adding Users To Firebase, Over Upon Registration In Javascript

I haven't seen any examples of this, but I want to purely interact with Firebase through the backend, and not the frontend with Javascript.

I have auth tokens being minted on my Go backend when a new user is added and then these users are written into a mongo database.

What I want is to be able to get a messaging token for my users, and then add it to their user document in mongo, that'll be used to send messages through the backend.

The reasoning is that we don't want to have to communicate with Firebase on our frontend.

Is this even possible?

Ad

Answer

If you want to send a message directly to a device with Firebase Cloud Messaging, you will definitely need some information from the client. There is no avoiding following the setup instructions on the client. In particular, you will have to handle the registration token on the client and send it to your backend so it can send the messages.

The Firebase Authentication token will not be useful to you at all for sending messages. FCM doesn't send messages to users - it sends messages to devices (or topics). You will have to figure out for yourself which devices belong to which users.

Ad
source: stackoverflow.com
Ad