only new records using firebase

前端 未结 2 791
陌清茗
陌清茗 2021-01-28 01:28

I´m using Firebase to get a list of messages. The problem is that I only need to see messages sent after I opened the page. Basically I don´t need to store the messages in the d

2条回答
  •  日久生厌
    2021-01-28 01:52

    The Firebase Database is not a message-passing mechanism, it is a state synchronization mechanism. If you want you can emulate a message passing mechanism on the database, but you'll have to do the work for that.

    One way to accomplish this is to write the message for each device that you want to send it to. That means that every device can simply delete each message that it reads and your database will never be bigger than the total number of unread message-devices.

    Another way is to store each message only once, but then track what devices have read it. Once every device has read it, you can delete the message. You'll need to store the "what devices have read each message" and the "list of all devices" in the database. This approach may require less storage, but it will definitely be more complex in code.

提交回复
热议问题