I\'m working in a friend request module for mobile app base on Firebase so I\'m considering to choose the way that notification is pushed.
Assume that userA request
Using either one should be fine.
However, a point to consider here is when keeping a listener active for the Real-time database, it also keeps an open socket on the user's device which adds to battery consumption.
While for FCM, it will only trigger once there is a notification is needed to be sent. If a friend request isn't really that app critical, I think using FCM is a way to go.
Have you also considered using both? If the user is currently online, it would be good to use the Real-time DB, but the childAdded
won't be triggered if the user is offline (not using the app for instance). In that case, you can set it so that a notification will be sent to the user.
The important thing in your scenario is that the friend request should be saved first in your database or app server, so that it will trigger the corresponding action (FCM notification or Real-time DB update).