Why I get the Notification just opening the Activity?

后端 未结 1 1788
Happy的楠姐
Happy的楠姐 2021-01-26 15:51

Edit : DO anyone have a solution for this on STACKOVERFLOW ?

I am using Firebase Database and wanted to show notification as soon as new child is added.

I am usi

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 16:22

    When you use addChildEventListener to attach a listener at a location in the database, onChildAdded will get called once for each child at that location, even if it isn't new. That's why your notification is always showing.

    If you only want to get "new" items, you will need to come up with a way to determine which children are actually new to the user, and filter for those children in your query. Maybe a timestamp or some other flag will work for you.

    0 讨论(0)
提交回复
热议问题