public void AddBox(BoxData boxData)
    {
        string json = JsonUtility.ToJson(boxData);

        Firebase.Database.DatabaseReference dbRef = Firebase.Database.FirebaseDatabase.DefaultInstance.RootReference;
        dbRef.Child("users").Push().SetRawJsonValueAsync(json);
    }
Exemple #2
0
    private T getFirebaseValue <T>(string path, string item)
    {
        Task <T> t = db.Child(path).Child(item)
                     .GetValueAsync()
                     .ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.LogError("GetValueAsync encountered an error: " + task.Exception);
                return(default(T));
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                return((T)snapshot.Value);
            }
            Debug.LogError("GetValueAsync encountered an error: " + task.Exception);
            return(default(T));
        });

        return(t.Result);
    }
	public void makeUser(string userid, string displayname) {
		string coderef = "" + randomCode();

		fb.Child("friend_codes").Child(coderef).SetValueAsync(userid);
		fb.Child("users").Child(userid).Child("name").SetValueAsync(displayname);
		fb.Child("users").Child(userid).Child("friend_code").SetValueAsync(coderef);
	}