查询和更新在智能手机中不起作用,但在模拟器 (Cloud Firestore) 中可以
Cloud Firestore 显示警告: “除非您更新安全规则,否则 Cloud Firestore 数据库将开始拒绝客户请求”。
然后查询和更新在智能手机中不起作用,但在 Android Studio 模拟器中是。
应用程序需要身份验证。用户注册时,数据会保存在身份验证中,但不会保存在 Cloud Firestore 集合中。
我的安全规则代码:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
答案 0 :(得分:0)
您的 Firestore 规则配置为没有人(对于用户)可以修改您的 Firestore 数据库。如果您只需要可以在 Firestore 数据库中读写的经过身份验证的用户,您应该更新您的 Firestore 规则,如下例所示:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
<块引用>
当用户注册时,数据会保存在身份验证中,但不会保存在 Cloud Firestore 集合中。
这是正确的,它不会自动保存,您应该使用代码手动保存它。 Firebase Authentication 中的字段数量有限,例如电子邮件和电话号码,但您可以检索它。要为您的用户添加更多详细信息,您可以使用 Firestore,为用户创建一个集合并在全名、年龄等字段中存储用户的其他详细信息。