带有 Parse 和 Xamarin .NET 的 Hello World 云功能 [英] Hello World Cloud Function with Parse and Xamarin .NET
问题描述
我正在尝试按照 Parse.com 上提供的教程从 .Net API 调用 CloudFunctions.
I'm trying to follow the tutorials available on Parse.com for calling CloudFunctions from the .Net API.
显然,这应该有效:
var result = await ParseCloud.CallFunctionAsync<IDictionary<string, object>>("hello", new Dictionary<string, object>());`
在 Xamarin 中调用时:
When calling in Xamarin:
button.Click += async (sender, e) => {
var result = await ParseCloud.CallFunctionAsync<IDictionary<string, object>> ("hello", new Dictionary<string, object>());
};
它只会锁定我的移动应用.调用时:
It just locks up my mobile app. When calling:
button.Click += async (sender, e) => {
var obj = new ParseObject("Note");
obj ["text"] = "Hello, world! This is a Xamarin app using Parse!";
obj ["tags"] = new List<string> {"welcome", "xamarin", "parse"};
await obj.SaveAsync ();
};
它成功地将一个对象保存到 Parse.
It successfully saves an object to Parse.
当使用 curl 调用hello"云函数时,它完美运行并返回Hello World"
When calling the 'hello' Cloud Function using curl, it works perfectly and returns 'Hello World'
我不明白我在这里做错了什么.有什么建议吗?
I don't understand what I'm doing wrong here. Any suggestions?
推荐答案
var result = await ParseCloud.CallFunctionAsync<string>("hello", new Dictionary<string, object>());
Toast.MakeText(this,result.ToString(),ToastLength.Short).Show();
那是因为他们网站上的例子是错误的!它应该是 CallFunctionAsync
,而不是 CallFunctionAsync
因为返回的类型是字符串!
It was because the example on their website was wrong! It should be CallFunctionAsync<string>
, not CallFunctionAsync<IDictionary<string, object>>
as the type being returned is a string!
啊啊啊啊.希望这对未来的人有所帮助.
Arrrrhhhh. Hopefully this helps someone in the future.
根据 Parse 的开发人员的说法,这应该现在/很快修复.
According to the developers at Parse, this should be fixed now / soon.
这篇关于带有 Parse 和 Xamarin .NET 的 Hello World 云功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!