这个问题在这里已有答案:
我知道这是一个常见的问题,但我没有找到我之前的问题。
我创建了一个新的firebase项目,我正在尝试使用它。我创建了公共所以每个人都可以实际使用:
权限
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
但是当我试图发布一个对象时,我遇到了一个错误:
错误:未捕获(在承诺中):错误:PERMISSION_DENIED:权限被拒绝错误:PERMISSION_DENIED:权限被拒绝
如果数据库当前是公开的,我怎么能拥有权限?我该怎么解决?
我的代码非常简单:
宾语
export class Coordenate {
$key: string;
latitude: number;
longitude: number;
}
打字稿组件
onAddMarker(event) {
this.databaseService.postCoordenate(event.coords.lat, event.coords.lng);
//this.latitude = event.coords.lat;
//this.longitude = event.coords.lng;
}
服务
listToStore: AngularFireList<any>;
//Insert a new bet
postCoordenate(latitude, longitude) {
this.listToStore = this.db.list("coordenates");
//Get the value of the photo URL in subscribe
this.listToStore.push({
latitude: latitude,
longitude: longitude
});
}
在我的角度项目中,firebaseConfig
加入了我的environment
这是因为您的规则对于firebase云防火墙是公开的,但您正在尝试将数据写入firebase实时数据库。选择firebase实时数据库并应用以下规则:
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": true,
".write": true
}
}