iterate though data in firebase unity code example

Example: iterate though data in firebase unity

public void GetUsers(List<User> users)
{
        FirebaseDatabase.DefaultInstance
  .GetReference("users")
        .GetValueAsync().ContinueWith(task =>
         {
                 if (task.IsFaulted) {
      // Handle the error...
                    Debug.Log("Error was:"+task.Exception.Message);
                    Debug.LogError("Error was:"+task.Result.Children);
            }
            else if (task.IsCompleted) {
            DataSnapshot snapshot = task.Result;
            // Do something with snapshot...
                        foreach(DataSnapshot s in snapshot.Children){
                        IDictionary dictUsers = (IDictionary)s.Value;   
                        Debug.Log(dictUsers["displayName"]);                    
                    }   
                    // After this foreach loop in snapshot.Children, nothing executes
                    UIManager.instance.ShowOtherUsers();
            }
  });
}

Tags:

Misc Example