2017-06-22 26 views
0

我正在开发一个Xamarin.Forms项目,并且遇到了一个非常奇怪的问题。这段代码实际上是在Xamarin.Droid项目中执行的。调用InvokeApiAsync移动应用程序服务

当我尝试这样做

var user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Facebook); 

if (user != null) 
{ 
    try 
    { 
     // executes this line 
     var userInfo = await client.InvokeApiAsync("/.auth/me"); 
     // down here nothing is executed and userInfo is never set with the data 
    } 
    catch (Exception e) 
    { 
     // never enter to this block 
    } 
} 

用户信息变量从未被设定的数据,并没有异常,没有在输出少见。

我已经尝试client.InvokeApiAsync(“/。auth/me”,HttpMethod.Get,null)但没有任何作品。

我知道这是相当短的信息,但我没有别的,因为没有例外引发。

谢谢。

回答

0

我终于想通了什么问题。启动身份验证逻辑的事件处理程序返回void而不是Task,因此异步调用在调用await之后不会继续。

这是提醒。

谢谢@Amor - MSFT为您解答。

1

我跟着this article添加身份验证到我的Xamarin Forms应用程序。它在我身边很好地工作。有一些事情需要检查你的项目。

  1. 您是否已将Azure移动服务发布到Azure并打开身份验证&已配置的Facebook应用程序ID和密码。

enter image description here

  • 你从手机客户端连接您的移动服务。
  • enter image description here

    相关问题