ios - 火力基地。 swift :Retrieve a message after 5 hours of the post

标签 ios swift firebase firebase-realtime-database

我正在 iOS 中开发一个消息传递应用程序,它可以让用户选择延迟发送消息一段特定的时间(例如,在 5 小时后发送此文本)并且我使用 Firebase 作为我的数据库。任何人都知道如何实现此功能?

具体来说:

每次发送消息时,我都使用 Firebase.child(XXX).setValue(message) 将新消息添加到 firebase

然后使用 Firebase.child(XXX).observeEventType(.ChildAdded,... 获取新发送的消息

有什么方法可以延迟 setValue 操作一段时间,从而实现功能?或者有更好的方法。

最佳答案

Firebase 中没有开箱即用的东西。

这里最简单的解决方案是将 validFrom 之类的字段添加到您的消息中,并在客户端通过该字段过滤所有消息。

您甚至可以添加 validTo 字段并使消息过期!

关于ios - 火力基地。 swift :Retrieve a message after 5 hours of the post,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39629348/

相关文章:

node.js - 使用 node.js 登录 Firebase-Admin

android - 与 firebase 11.8.0 和 google-services 插件 3.1.2 冲突

ios - MKPinAnnotationView 不起作用

ios - UIPageViewController 在 iOS 13 上使 UItalkeViewController "jump"

ios - UITableViewCell 的 textLabel 的字体变化没有视觉上的变化

swift - 最低操作系统版本 Not Acceptable

javascript - 将 Firebase 与 Redux 绑定(bind)

ios - 从 ParseUI 更改 UITextField

ios - 为当前用户 Firebase 创建静态变量?

swift - 如何在允许 JWT 刷新的同时检查 Swift 中的 Auth 用户?