【问题标题】:Invoking InvokeApiAsync Mobile App Services调用 InvokeApiAsync 移动应用服务
【发布时间】:2017-06-23 23:08:30
【问题描述】:

我正在开发一个 Xamarin.Forms 项目,但遇到了一个非常奇怪的问题。这段代码实际上是在 Xamarin.Droid 项目中执行的。

当我尝试这样做时

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
    }
}

userInfo 变量永远不会与数据一起设置,并且在输出中没有异常和罕见的情况。

我已经尝试过 client.InvokeApiAsync("/.auth/me", HttpMethod.Get, null) 但也没有用。

我知道这是很短的信息,但我没有其他任何信息,因为没有引发异常。

谢谢。

【问题讨论】:

    标签: xamarin xamarin.forms azure-mobile-services


    【解决方案1】:

    我关注 this article 将身份验证添加到我的 Xamarin Forms 应用程序。它在我这边工作得很好。您需要对项目进行一些检查。

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

    1. 您是否从移动客户端连接了移动服务。

    【讨论】:

      【解决方案2】:

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

      这是提醒。

      感谢@Amor - MSFT 的回答。

      【讨论】:

        猜你喜欢
        • 2023-03-27
        • 1970-01-01
        • 1970-01-01
        • 2016-04-10
        • 2018-10-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多