Skip to content

Instantly share code, notes, and snippets.

@neogeek
Last active April 13, 2019 23:52
Show Gist options
  • Save neogeek/a238b9c8163b3a762e5f12db2ae4c515 to your computer and use it in GitHub Desktop.
Save neogeek/a238b9c8163b3a762e5f12db2ae4c515 to your computer and use it in GitHub Desktop.
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public static class FirebaseDatabase
{
public static IEnumerator Send<T>(string firebaseUrl, T content)
{
return Send(firebaseUrl, JsonUtility.ToJson(content));
}
public static IEnumerator Send(string firebaseUrl, string jsonData)
{
using (UnityWebRequest request = UnityWebRequest.Put(firebaseUrl, jsonData))
{
request.method = "PATCH";
Debug.LogFormat("firebaseUrl: {0}", firebaseUrl);
Debug.LogFormat("jsonData: {0}", jsonData);
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError)
{
Debug.LogError(request.error);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment