angels65
angels65

Reputation: 57

How to receive a notification to android user, when ever firebase database is updated?

I have an android application connected with firebase. When ever a new child is added to the database I need the user to be notified via a notification message. Moreover, in my application the user selects a code (eg: 71000,00100,90288) and this code is stored in shared preferences. I need the user to be notified when ever a child is added or modified, only as the code selected by the user. Any help, highly appreciated.Thank you so much in advance.

enter image description here

Upvotes: 0

Views: 367

Answers (3)

Tarlan
Tarlan

Reputation: 76

Once i developed such application, in order to achieve this i used broadcastreceiver which was monitoring my data base for new information. (It is just suggestion) But u can still make use of this tutorial

Upvotes: 0

Jay
Jay

Reputation: 493

On firebase, we got callbacks to provide realtime database functionalities.

Ways of doing so:

  • Register a onChildAdded listener to the firebase node URL and it get triggered whenever a child is added and you can run a service that could cause notification payload which run on client side.
  • use Firebase cloud functions which run on service side.

Upvotes: 0

Ouail Bellal
Ouail Bellal

Reputation: 1794

if your server side is firebase ,to send notification when child added , you need to create a firebase cloud function which will do that so this what you will do :

  • create firebase cloud function
  • send data with notification ( using payload )
  • after receiving data in your service ( Messaging listner )check if the data ( number ) is equal to some of saved numbers in shared preferences

Upvotes: 1

Related Questions