【问题标题】:iOS - How to disable the Firebase caching?iOS - 如何禁用 Firebase 缓存?
【发布时间】:2017-04-24 18:32:13
【问题描述】:

我在 firebase 节点中删除了 post 对象。

但是当我查询帖子对象时,会显示以前缓存的帖子对象。

我没有从 firebase 获取刷新数据。

问题: 有没有办法在 iOS 中停止 firebase 缓存并从 firebase 获取刷新的数据?

我的代码:

self.firPostRef.child(userID).observeSingleEvent(of: .value, with: { (snapshot) in
        if snapshot.value is NSNull { completion(nil) }
        else {
            //print(snapshot.debugDescription)
            let postids = Array((snapshot.value as! [String:AnyObject]).keys)

            print(postids)
            completion(postids)

        }
    }) { (error) in
        debugPrint("error occured in getting all comments -" + error.localizedDescription)
    }

【问题讨论】:

    标签: ios firebase firebase-realtime-database


    【解决方案1】:

    使用observeSingleEventOfType,reference.keepSynced(true)。执行此代码后,它会刷新数据。

    使用observeEventOfType。这将始终使您的数据保持同步,并在您进行更改后立即再次执行。

    【讨论】:

      【解决方案2】:

      解决方案:

      只需使用以下代码禁用 firebase 缓存:

              FIRDatabase.database().reference().keepSynced(false)
      

      塔达..

      【讨论】:

      • 我怎样才能让它在 TypeScript for Firecast 中工作
      猜你喜欢
      • 2015-12-22
      • 2017-07-14
      • 2014-10-05
      • 2018-02-18
      • 2019-02-24
      • 2022-07-23
      • 1970-01-01
      • 2011-02-20
      • 2012-04-29
      相关资源
      最近更新 更多