Keiran Paster
Keiran Paster

Reputation: 600

How to send messages to specific people in FireBase

I am learning how to use Firebase and I'm really confused about how you would send a chat message to a specific person in Firebase. Basically what I want to do is have a 2 way chat between 2 people, but other people can make other chats with other friends also. Would you need a new Firebase for each chat?

Upvotes: 1

Views: 1508

Answers (2)

Thịnh Phạm
Thịnh Phạm

Reputation: 2663

if A want to chat with B, A send messages (push) to

http://your-fire-base.firebaseio.com/b_id/ (B's channel) 

with content

{sender: a_id, data: some_data}

B will subscribe to his own channel and filter the data based on sender.

Upvotes: 6

Frank van Puffelen
Frank van Puffelen

Reputation: 599601

You can create nodes under a single Firebase to accomplish most scenarios.

In your case, I'd set up a hierarchy like this:

<root>

  Frank-Keiran

    <messages>

  Keiran-User123

    <messages>

Upvotes: 1

Related Questions