public IEnumerator QueryChannelsDBPlayers() { var func = functions.GetHttpsCallable("QueryChannelsDBPlayers"); var data = new Dictionary <string, object>(); data["platform"] = platform; data["channel"] = channelName; var task = func.CallAsync(data).ContinueWithOnMainThread((callTask) => { if (callTask.IsFaulted) { Debug.Log("FAILED!"); Debug.Log(String.Format(" Error: {0}", callTask.Exception)); return; } var result = (IDictionary)callTask.Result.Data; playersFromDB = JsonConvert.SerializeObject(result["playersFromDB"]); dataBasePlayers = JsonConvert.DeserializeObject <List <Player> >(playersFromDB); // playerDBDictionary = dataBasePlayers.ToDictionary(p => p.UserName, p => p); // playerDBDictionary["varcy0n"].Coin +=20; // dataBasePlayers = playerDBDictionary.Values.ToList(); }); yield return(new WaitUntil(() => task.IsCompleted)); }
/// <summary> /// Functions addEntryを実行する /// require: 認証済み /// </summary> /// <param name="entry"></param> /// <returns></returns> public async Task <object> AddEntryAsync(RankingEntry entry) { object data = new Dictionary <object, object> { { "name", entry.Name }, { "score", entry.Score }, }; return(await functions.GetHttpsCallable("addEntry").CallAsync(data) .ContinueWith(task => { return task.Result.Data; })); }
private void Awake() { manager = GetComponent <UIManager>(); FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread <DependencyStatus>((task) => { DependencyStatus status = task.Result; if (status == DependencyStatus.Available) { App = FirebaseApp.DefaultInstance; Auth = FirebaseAuth.DefaultInstance; functions = FirebaseFunctions.DefaultInstance; functionReference = functions.GetHttpsCallable("RequestMessage"); manager.TurnOff(manager.AuthBlocker); manager.TurnOff(manager.AnalyticsBlocker); App.SetEditorDatabaseUrl("https://fir-n-ix.firebaseio.com/"); dbReference = FirebaseDatabase.DefaultInstance.RootReference; FirebaseMessaging.TokenReceived += OnTokenReceived; FirebaseMessaging.MessageReceived += OnMessageReceived; FirebaseMessaging.TokenRegistrationOnInitEnabled = true; defaults.Add("RemoteTest", 25); FirebaseRemoteConfig.SetDefaults(defaults); FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread((remoteConfigTask) => { FirebaseRemoteConfig.ActivateFetched(); RemoteConfigResult = FirebaseRemoteConfig.GetValue("RemoteTest").StringValue; manager.TurnOff(manager.RemoteConfigBlocker); }); storage = FirebaseStorage.DefaultInstance; } else { Debug.Log(string.Format("Can't resolve all Firebase dependencies: {0}", status)); } }); }
public CallFunction(FirebaseFunctions functions, string functionName) { functions.GetHttpsCallable(functionName).CallAsync().ContinueWith(task => { Result = task.Result; _finished = true; }); }
/// <summary> /// Executes a remote function and return async result /// </summary> /// <param name="functionName"></param> /// <param name="data"></param> /// <returns></returns> public Task <HttpsCallableResult> CallRemoteFunction(string functionName, Dictionary <string, object> data) { var function = _functions.GetHttpsCallable(functionName); // Because context on firebase functions is not populated on all cases -.- if (_auth != null) { data["uid"] = _user.UserId; } return(function.CallAsync(data)); }
public async Task AddNotification(Models.Notification newNotif, string functionCall) { TaskCompletionListener taskCompletionListener = new TaskCompletionListener(); var app = FirebaseApp.InitializeApp(_context); firebaseFunc = FirebaseFunctions.GetInstance(app); var func = firebaseFunc.GetHttpsCallable(functionCall) .Call(JsonConvert.SerializeObject(newNotif)) .AddOnSuccessListener(_activity, taskCompletionListener); taskCompletionListener.Succes += TaskCompletionListener_Succes; taskCompletionListener.Failure += TaskCompletionListener_Failure; }
// Runs the given test and returns whether it passed. public Task RunAsync(FirebaseFunctions functions, Utils.Reporter reporter) { var func = functions.GetHttpsCallable(Name); return(func.CallAsync(Input).ContinueWith((task) => { if (ExpectedError == FunctionsErrorCode.None) { // We expected no error. if (task.IsFaulted) { // The function unexpectedly failed. throw task.Exception; } // The function succeeded. if (!Utils.DeepEquals(ExpectedData, task.Result.Data, reporter)) { throw new Exception(String.Format("Incorrect result. Got {0}. Want {1}.", Utils.DebugString(task.Result.Data), Utils.DebugString(ExpectedData))); } return; } // The function was expected to fail. FunctionsException e = null; foreach (var inner in task.Exception.InnerExceptions) { if (inner is FunctionsException) { e = (FunctionsException)inner; break; } } if (e == null) { // We didn't get a proper Functions Exception. throw task.Exception; } if (e.ErrorCode != ExpectedError) { // The code wasn't right. throw new Exception(String.Format("Error {0}: {1}", e.ErrorCode, e.Message)); } reporter(String.Format(" Got expected error {0}: {1}", e.ErrorCode, e.Message)); })); }
private Task <string> NoficiataionPushing(string notificationText) { // Create the arguments to the callable function. var data = new Dictionary <string, object>(); data["naslov"] = "Tedenski Meni"; data["vsebina"] = notificationText; // Call the function and extract the operation from the result. var function = functions.GetHttpsCallable("PushCustomNotificaion"); return(function.CallAsync(data).ContinueWith((task) => { return (string)task.Result.Data; })); }
private Task <float> FetchPercentile(float time, string levelNum) { var data = new Dictionary <string, object>(); data["level"] = levelNum; data["time"] = time; var function = func.GetHttpsCallable("getPercentile"); return(function.CallAsync(data).ContinueWith((task) => { var json = JsonConvert.SerializeObject(task.Result.ToDictionary()); var dict = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, float> > >(json); return dict["Data"]["percentile"]; })); }
protected IEnumerator AddNumbers(int firstNumber, int secondNumber) { var func = functions.GetHttpsCallable("addNumbers"); var data = new Dictionary <string, object>(); data["firstNumber"] = firstNumber; data["secondNumber"] = secondNumber; var task = func.CallAsync(data).ContinueWithOnMainThread((callTask) => { if (callTask.IsFaulted) { // The function unexpectedly failed. DebugLog("FAILED!"); DebugLog(String.Format(" Error: {0}", callTask.Exception)); return; } // The function succeeded. var result = (IDictionary)callTask.Result.Data; DebugLog(String.Format("AddNumbers: {0}", result["operationResult"])); }); yield return(new WaitUntil(() => task.IsCompleted)); }
public IHttpsCallable GetHttpsCallable(string name) { return(new HttpsCallableWrapper(_functions.GetHttpsCallable(name))); }