android - Firestore 实现通知 View

标签 android ios firebase google-cloud-firestore nosql

所以这个问题首先与推送通知无关。我想要实现的是一个显示所有通知的 View 。像 Instagram 或 Facebook 这样的东西。

这些通知可能来自许多资源。比方说:

  1. 有人喜欢我的照片。 (来自 likes 表。)
  2. 有人评论了我的照片。 (来自 comments 表。)
  3. 新促销。 (来自 promotions 表。)
  4. 新的安全警报。 (来自 alerts 表。)

重要的是我只需要为每个项目显示一行。因此,如果有 10 个人喜欢这张照片,我想实时更新那一行。 另一个重要的事情是分页。这就是我遇到困难的地方。当这些资源来自不同的表时,很难实现分页。

所以我的问题是:我应该创建另一个 notifications 表并且每当执行一个操作时,我向该表插入一个新行然后在此处执行分页查询,或者我应该先获取然后再执行合并来自不同表的这些通知?

最佳答案

我是否应该创建另一个通知表,每当执行一个操作时,我向该表插入一个新行,然后在此处执行分页查询?

If you are implementing this approach, it will be easy for fetching a query with pagination. I take just an example if someone is like your photo then you have all the table fields like postId, userId, and all. So you can put all the values in the 'Notification' table.

我应该从不同的表中获取然后合并这些通知吗?

This will be difficult to fetch or join different tables to show notification with pagination. It will also take time to execute queries in the database.

关于android - Firestore 实现通知 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62473993/

相关文章:

ios - 什么时候在 Objective-C 中使用 self?

ios - Xcode "Size to fit contents"禁用

objective-c - 我可以像NSClassFromString和NSSelectorFromString一样做NSVariableFromString吗?

javascript - 在 Firebase 上部署 Angular2 应用程序

android - 库版本 11.2.0 的 firebase ProGuard 错误(警告)

java - react native : How to fix version issue in Gradle

java - Android - 无法解析以下类的父类(super class)型 - (Room Persistant Library,Android Library Module)

java - Android比较特殊字母

android - 如何使用主页按钮终止应用程序

android - 使用Firebase时 flutter 中的 Gradle 问题