By Yayayaya


2019-11-08 14:13:12 8 Comments

I know how to read data from the firebase database, in my database structure, there is a child with various nodes written and pushed by users. How can I add a listener that will tell me whenever a new node has been added in the child and trigger a notification. Please note I already have a method for creating a notification. I don't want to know the contents of the child added, I just want to know whenever a new child is added. How would I go about this?

1 comments

@Gastón Saillén 2019-11-08 14:52:47

For this feature you will need to use Firebase functions with Database Triggers

You can see an example for this function here

Basically how it works

  • You write a function (typescript/javascript)
  • You deploy that function into Firebase Functions Since you used Database Triggers in your function, the function will trigger whenever a new item is inserted inside the node you are listen for
  • The trigger for this is onCreate()
  • You will make a notification payload that will be sent to the user device token you stored inside your child node

@Yayayaya 2019-11-08 15:03:27

Am looking for a way to do this within the android app itself

@Gastón Saillén 2019-11-08 15:05:35

You can also use ChildEventListener to listen for childs added to a certain node firebase.google.com/docs/reference/android/com/google/fireba‌​se/…

@Yayayaya 2019-11-08 19:07:38

Oh, okay thank you I will try that

Related Questions

Sponsored Content

2 Answered Questions

41 Answered Questions

[SOLVED] How do I efficiently iterate over each entry in a Java Map?

43 Answered Questions

[SOLVED] How do I convert a String to an int in Java?

65 Answered Questions

[SOLVED] How do I generate random integers within a specific range in Java?

  • 2008-12-12 18:20:57
  • user42155
  • 3900067 View
  • 3359 Score
  • 65 Answer
  • Tags:   java random integer

57 Answered Questions

[SOLVED] How do I read / convert an InputStream into a String in Java?

8 Answered Questions

[SOLVED] Get users by name property using Firebase

2 Answered Questions

[SOLVED] Android - Firebase database child node

1 Answered Questions

Sponsored Content