I am trying to use firestore to certain data,but i can't see any data in firestore console error:
(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}.
Although i allowed read,write in rules to true.
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:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Replace your rules with this and try:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{multiSegment=**} {
allow read, write;
}
}
}
I solved the problem by creating a new project.Becuase it seems that there was a problem in project id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With