gpt4 book ai didi

swift - Firestore 权限不足

转载 作者:可可西里 更新时间:2023-11-01 01:08:41 24 4
gpt4 key购买 nike

我一直收到这个错误:

Adding Post Error: Missing or insufficient permissions.

这些是我当前的权限,允许任何人做任何事情(这并不理想,但我只是在测试)。

service cloud.firestore {
match /databases/{database}/documents {
match /Posts {
allow read, write;
}
}
}

我尝试运行的代码是:

func addPost (postID: String, date: NSDate, link: String, profileID: String, text: String) {
let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true
db.settings = settings
db.collection("Posts").document(postID).setData(["Date": date, "Link": link, "ProfileID": profileID, "Text": text]) { (error) in
if (error != nil) {
print ("Adding Post Error: " + error!.localizedDescription)
} else {
print("Post added sucessfully")
}
}

}

为什么我会收到此错误消息?截至 2018 年 6 月 27 日,我运行的是最新版本的 FirebaseFirestore

最佳答案

我很确定您需要指定允许用户访问集合中的文档,如documentation on basic read/write rules 中所示:

service cloud.firestore {
match /databases/{database}/documents {
match /Posts/{post} {
allow read, write;
}
}
}

上面的区别是 match/Posts/{post} 中的 {post}

关于swift - Firestore 权限不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51073866/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com