即使没有"故障"数据库也不会写入。退回

时间:2017-07-27 21:57:40

标签: firebase unity3d firebase-realtime-database

我试图让Firebase数据库组件与我的iOS项目一起工作,当我的代码(包含在下面)执行时,它将输出"成功"消息,但数据库未被修改。我还包括了一个"错误"我收到了我的Xcode日志。

感谢您的帮助!



public IEnumerator GetProfile() {
  Task < DataSnapshot > task = FirebaseDatabase.DefaultInstance.GetReference("users/" + _currentUser.UserId).GetValueAsync();

  while (!task.IsFaulted && !task.IsCanceled && !task.IsCompleted)
    yield
  return null;

  if (task.IsCompleted) {
    //set data
    Debug.Log("has data");
    DataSnapshot snapShot = task.Result;
    if (snapShot.Value == null) {
      Debug.Log("no value");
      Task postNew = FirebaseDatabase.DefaultInstance.RootReference.Child("users").Child(_currentUser.UserId)
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(new User()));

      while (!postNew.IsFaulted && !postNew.IsCanceled && !postNew.IsCompleted)
        yield
      return null;

      if (postNew.IsFaulted) {
        Debug.Log(postNew.Exception.ToString());
      } else
        Debug.Log("suceeded");
    }
  } else {
    Debug.Log(task.Exception.ToString());
    /*_root.Child("users").Child(_currentUser.UserId)
    	 .SetRawJsonValueAsync(JsonConvert.SerializeObject(new User()));*/
  }
}
&#13;
&#13;
&#13;

&#34;错误&#34;

&#13;
&#13;
<Error> [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: ...
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

原来我发送的JSON字符串的值为&#34; null&#34;所以写得无声无息。 (如果另一位开发人员帮我找到它)。