'Difference between event child_added of Realtime Database Firebase vs Firebase Cloud function

I having a case where I need to receive notification whenever Realtime Database Firebase have new data. When investigate, I found out there are 2 way to do this in client side (mobile app using React Native):

Can someone please tell me what is the difference between 2 way and pros and cons of each way?. The document is not helpful for me about this.

Note:

  • Backend Server written in Java framework Spring boot response function push new data to Realtime Database Firebase.
  • Client side need to receive notification when new data added to Realtime Database Firebase (currently only mobile app written in React Native but I also need to do it for web in the future)


Solution 1:[1]

Paraphrasing Frank Van Puffelen's comment as an answer:

Firestore and Realtime databases are two completely separate databases. Though firestore and Realtime database both are part of Firebase. If you want to trigger a cloud function from Real Time database, please follow this documentation. If you want to trigger cloud function from Firestore, please check this documentation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1