I made a chat using firebase and I implemented this functionality on the web and also on an ios app. I implemented both FCM sdks inside my applications and I can make request using curl and/or the firebase console both applications receive this notifications. The functionality for background and foreground works perfectly so I'm not having any issues with this aspect.
Now the real issue is that I'm having some struggles because I do not know how to send a notification from chat to chat, if the app user is outside the windows and the web user sends it a message I want to show him a notification, I can see that the curl sends an api request to an fcm url.
My question is do I need to make an api endpoint in my server that calls the fcm url in order to receive the notifications in my clients or there is a way to make a call directly to my client in order to display or not the notification?. I'm really lost at this and the firebase documentation do not explain this part also some of the answers I found here I do not fully comprehend them.
Any help would be highly appreciated!