0

私がここでやろうとしているのは、実際にファイアストアからデータを読み取ることだけです。私はRNFのドキュメントからすべてのインストールに従ったが、私は私の文書からデータを取得したり、単にfirestoreコレクションに参照しようとすると、エラーが現れます:反応するネイティブfirebase firestoreの許可が拒否されました

react native firebase error

私は、私はそれを考えたとして、(ルールを変更してみましたルールは関係していたが運がなかった)。ここ は私のデータベース構造である:

database structure

そして、以下は私のコードです:

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> 
    ); 
    } 
} 

私はこのエラーを解決することができますか?

+0

ルールを(画像またはテキストとして)投稿できますか? –

答えて

0

ファイアストアのデフォルト設定では、アクセスを無効にします。

アクセスルールが設定されていない場合、データをフェッチできません。

はこれにそれらを変更し

- しかし、唯一のテストのために:

service cloud.firestore { match /databases/{database}/documents { // Match all documents, recursively, with a wildcard and the "=**" recursive modifier match /{document=**} { allow read, write; } } }

そして、それが動作した後 - hereについての詳細を読みます。

+1

私はあらかじめそれを変更しようとしましたが、それでも同じエラーが出ます。 –

+0

デバッグ用のstackblitzを作成できますか? – DauleDK

関連する問題