react本机firebase firestore权限被拒绝

react本机firebase firestore权限被拒绝,firebase,react-native,permission-denied,google-cloud-firestore,Firebase,React Native,Permission Denied,Google Cloud Firestore,我想做的是从firestore中读取数据。我遵循了RNF文档中的所有安装过程,但当我尝试从文档中获取数据或仅引用firestore集合时,会出现一个错误: 我试图改变规则(因为我认为这是涉及到的规则),但没有运气。 以下是我的数据库结构: 下面是我的代码: import React, { Component } from 'react'; import {View, Text, FlatList, Image, StyleSheet, Button, TouchableHighlight}

我想做的是从firestore中读取数据。我遵循了RNF文档中的所有安装过程,但当我尝试从文档中获取数据或仅引用firestore集合时,会出现一个错误:

我试图改变规则(因为我认为这是涉及到的规则),但没有运气。 以下是我的数据库结构:

下面是我的代码:

import React, { Component } from 'react';
import {View, Text, FlatList, Image, StyleSheet, Button, TouchableHighlight} from 'react-native';
import firebase from 'react-native-firebase';
import MainApp from './src/screen/test';

export default class App extends Component<{}> {
  constructor(){
    super();
    this.itemsRef = this.getRef('questions');
    this.state = {
      items:[],
      loading:true,
    };

  }

  setModalVisible(visible){
    this.setState(modalVisible:visible);
  }
  getRef(location){
    return firebase.firestore().collection('chat');
  }
  componentWillMount(){
    this.getItems(this.itemsRef);
  }
  componentDidMount(){
    //this.getItems(this.itemsRef);
  }
  getItems(itemsRef){
    firebase.firestore().collection('Users').get().then((snap)=>{
      let items =[];
      alert(snap);
      snap.forEach((childSnap)=>{
        items.push({
        title:childSnap.val().question,
        _key:childSnap.key
        });
        alert(childSnap.key)
      })
      this.setState({
        items,
        loading:false
      })
    })
  }
  pressRow(item){
    alert(item);
  }
  renderRow(item){
    return(
      <TouchableHighLight onPress={()=>{
        this.pressRow(item)
      }}>
      <View>
      <Text>{item.title}</Text>
      </View>
      </TouchableHighLight>
    )
  }
  addItem(){

  }
  render() {
    if (this.state.loading) {
    return null; // or render a loading icon
    }
    return (
      <View style={{ flex: 1 }}>
      <FlatList
        data={this.state.items}
      />
      <Button
          title={'Add TODO'}
          onPress={() => console.log()}
      />
  </View>
    );
  }
}
import React,{Component}来自'React';
从“react native”导入{视图、文本、平面列表、图像、样式表、按钮、TouchableHighlight};
从“react native firebase”导入firebase;
从“/src/screen/test”导入MainApp;
导出默认类应用程序扩展组件{
构造函数(){
超级();
this.itemsRef=this.getRef('questions');
此.state={
项目:[],
加载:对,
};
}
setModalVisible(可见){
此.setState(modalVisible:可见);
}
getRef(位置){
返回firebase.firestore().collection('chat');
}
组件willmount(){
this.getItems(this.itemsRef);
}
componentDidMount(){
//this.getItems(this.itemsRef);
}
getItems(itemsRef){
firebase.firestore().collection('Users').get().then((snap)=>{
设项目=[];
警报(snap);
snap.forEach((childSnap)=>{
推({
标题:childSnap.val().问题,
_key:childSnap.key
});
警报(childSnap.key)
})
这是我的国家({
项目,
加载:错误
})
})
}
按行(项目){
警报(项目);
}
渲染箭头(项目){
返回(
{
此按钮。按行(项目)
}}>
{item.title}
)
}
附加项(){
}
render(){
if(this.state.loading){
返回null;//或呈现加载图标
}
返回(
console.log()}
/>
);
}
}

如何修复此错误?

firestore的默认设置是禁用访问

因此,如果没有设置访问规则,则无法获取数据

将其更改为此-但仅用于测试:

service cloud.firestore{
匹配/databases/{database}/documents{
//使用通配符和“=**”递归修饰符递归匹配所有文档
匹配/{document=**}{
允许读、写;
}
}
}


然后,在它工作之后-阅读更多关于firestore的信息。

firestore的默认设置是禁用访问

因此,如果没有设置访问规则,则无法获取数据

将其更改为此-但仅用于测试:

service cloud.firestore{
匹配/databases/{database}/documents{
//使用通配符和“=**”递归修饰符递归匹配所有文档
匹配/{document=**}{
允许读、写;
}
}
}


然后在它工作后-阅读更多信息。

您可以发布您的规则(图片或文本)吗?您可以发布您的规则(图片或文本)吗?您可以尝试创建用于调试的stackblitz吗?您可以尝试创建用于调试的stackblitz吗?