Firestore 更新使应用程序崩溃

Posted

技术标签:

【中文标题】Firestore 更新使应用程序崩溃【英文标题】:Firestore update is crashing app 【发布时间】:2017-12-08 15:51:12 【问题描述】:
let dataRef = database.collection("stores").document(store.id).collection("data").document("storeData")

var storeData: [String:Any] = [:]
storeData["seq"] = store.seq + 1
storeData["shiftSeq"] = store.shiftSeq + 1
dataRef.updateData(storeData)

执行上述代码时,我收到以下错误。在我升级到最新版本的 Firebase/Firestore 之前它运行良好

* -[FSTWriteStream startWithDelegate:] 中的断言失败,third_party/firebase/ios/Source/Firestore/Source/Remote/FSTStream.m:244 2017-12-08 10:48:47.819586-0500 centroOne[1833:473631] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“FIRESTORE 内部断言失败:委托必须为零”

【问题讨论】:

我希望你的 pod 版本是 1.8.4。如果不是,请更新它然后运行 ​​pod update。 【参考方案1】:

我删除了附加到此文档的规则集,问题就消失了。规则集引用了另一个文档中的值以确保它存在。

【讨论】:

【参考方案2】:

我最近在 swift 中遇到了这个问题,并通过检查 documentId 是否存在来解决我的问题。在上述情况下,请检查您的 Firestore 数据库中的 store.id 退出,然后运行更新方法。

【讨论】:

以上是关于Firestore 更新使应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章

从 Firebase Firestore 检索时应用程序崩溃

Firestore RecyclerView 应用程序在运行时崩溃

使用带有 Firestore 的 collection.add() 应用程序崩溃

Chromecast 扩展控制器、曲目选择器对话框在 11.0.2 更新后使应用程序崩溃

Firestore 电话验证导致 ios 崩溃 (Flutter)

如何以编程方式使 Android 应用程序崩溃?