【发布时间】:2019-01-28 21:48:59
【问题描述】:
我的 Unity3D 调用 Firebase Functions 函数时遇到问题。我的代码其实是从https://firebase.google.com/docs/functions/callable复制过来的。
我的功能代码如下:(实际上只是复制了这个文件) https://github.com/firebase/quickstart-js/blob/a579893cfa33121952aeed9069c1554ed4e65b7e/functions/functions/index.js#L44-L50
在 Unity 中我有这个:
//Create the arguments to the callable function.
var data = new Dictionary<string, object>();
data["text"] = "message";
data["push"] = true;
//Call the function and extract the operation from the result.
var function = FirebaseFunctions.DefaultInstance.GetHttpsCallable("addMessage");
function.CallAsync(data).ContinueWith((task) => {
if (task.IsFaulted)
{
foreach (var inner in task.Exception.InnerExceptions)
{
if (inner is FunctionsException)
{
Debug.Log(inner.Message);
}
}
}
else
{
Debug.Log("Finished: " + task.Result.Data);
}
});
但是我得到了这个结果: 响应不是有效的 JSON 对象。
我做错了什么?
感谢您的帮助!!!
【问题讨论】:
-
你在哪一行得到错误?
标签: javascript firebase unity3d google-cloud-functions