Last active
April 13, 2019 23:52
-
-
Save neogeek/a238b9c8163b3a762e5f12db2ae4c515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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