Can I implement the concept of channels in Firebase?

The Firebase chat app seems to assume that all clients will receive messages sent to the specified FireBase address.

Now, one way to ensure that users only receive messages sent to a specific channel is to filter messages on the client, but this would mean that all messages will propagate to all clients, and the client will do the filtering.

Is there a way to set channels on the Firebase server - or does this mean that separate firebases will need to be created for separate channels, which would mean that if you want to use push messages for a specific user, you might need to create one channel / firebase for each user.

So what's the suggested solution?

+3


source to share


1 answer


Firebase Data Structure makes this pretty easy, really! The demo app puts chat messages in the Firebase root (i.e. https://samplechat.firebaseio.com/ ), but you can just as easily use separate locations in your Firebase for individual chats, like / chat 1, / chat2 and etc. Or better yet, you could have / chats / location with an arbitrary number of chats below them, each one uniquely (perhaps using push () ).



The user could then receive and push messages to a particular chat by referencing it directly (e.g. https://samplechat.firebaseio.com/chats/chat-id/ ) and then they would not receive any data for any other chats.

+4


source







All Articles