0
我試圖讓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)
\t .SetRawJsonValueAsync(JsonConvert.SerializeObject(new User()));*/
}
}
「錯誤」
<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: ...
您是否在App Delegate中調用FirebaseApp.configure()? –
我試過了,但是當我這樣做實際上會導致更多的錯誤;特別是關於如何配置Firebase應用。 –