【问题标题】:reading data from firebase using react native使用 react native 从 firebase 读取数据
【发布时间】:2019-05-20 14:44:49
【问题描述】:

下面是我的 App.js 文件的构造函数。

.Auth 函数运行良好.....因为当用户 auth 更改时,函数“onAuthStateChanged”运行。 但是,当我在 firebase 中更新 Profile 集合(手动使用 Web GUI)时,控制台不会记录任何内容。 Profile 集合是我的 FB 数据库中唯一的子集合。 谁能帮我调试一下?谢谢

  constructor(props) {
    super(props);

    //initialize firebase
    if (!Firebase.apps.length) {
      Firebase.initializeApp(firebaseConfig);
    }
    Firebase.auth().onAuthStateChanged(this.onAuthStateChanged);
    Firebase.database()
      .ref('Profile/')
      .on('value', (snapshot) => {
        console.log(snapshot.val());
      });
  }

【问题讨论】:

    标签: firebase react-native firebase-realtime-database


    【解决方案1】:

    代码是正确的......我只是没有在 Firebase 中设置数据库规则

     "rules": {
        ".read": true,
        ".write": true
      } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      • 2021-04-06
      相关资源
      最近更新 更多