0
votes

I'm developing a chat application, where there are chat rooms users can use to write messages. Inside a chat room they can choose to subscribe to that room. The purpose of this is to receive push notifications when new messages are added to the room.

My database structure

enter image description here

  1. Each chat room has a UID
  2. The members node consists of the chat room UID and the user id for the user subscribed to that chat room
  3. The messages node consists of the chat room UID and the messages for that chat room

Question I've looked at multiple tutorials of making push notifications between devices, but I can't seem to find a solution where a user only receives push notifications of subscribed chat rooms. Any idea of how I can achieve this?

2

2 Answers

2
votes

With Firebase you can send Notifications to users using their firebasetoken or to users who subscribed to a Topic.

Let anyone who subscribed to a Chatroom subscribe to a Topic at firebase and on new Messages inside the Chatroom you can send notifications to everyone who subscribed to that topic

0
votes

You can achieve this goal through Cloud Functions for Firebase.

You can achieve this goal in many ways, but in my openion cloud functions are the best one.

Create onCreate Trigger and implement your notification functions there.