我一直收到这个错误:

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;
    }
  }
}

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

10-07 19:26
查看更多