【发布时间】:2021-03-20 06:27:33
【问题描述】:
我正在尝试对某些数据使用 firestore,但我在 firestore 控制台中看不到任何数据 错误:
(c4326c7) Stream closed with status: Status{code=PERMISSION_DENIED, description=Cloud Firestore API has not been used in project 508621789005 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firestore.googleapis.com/overview?project=508621789005 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., cause=null}.
虽然我允许读,写规则为真。
val db = FirebaseFirestore.getInstance()
// Create a new user with a first and last name
val user: MutableMap<String, Any> = HashMap()
user["first"] = "Ada"
user["last"] = "Lovelace"
user["born"] = 1815
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener { documentReference ->
Log.d(
TAG,
"DocumentSnapshot added with ID: " + documentReference.id
)
}
.addOnFailureListener { e -> Log.w(TAG, "Error adding document", e) }
规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
【问题讨论】:
-
请分享您的数据库规则
-
我在帖子中添加了规则