【问题标题】:Calling Firebase Function from Unity throws error从 Unity 调用 Firebase 函数会引发错误
【发布时间】: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


【解决方案1】:

我仍在解决这个问题,突然间它奏效了。我不知道为什么要说实话,因为它看起来完全一样,我没有改变任何东西。

【讨论】:

    猜你喜欢
    • 2020-11-15
    • 2018-11-06
    • 1970-01-01
    • 2013-07-23
    • 1970-01-01
    • 2020-05-29
    • 2021-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多