【问题标题】:Kinvey-Xamarin: How to recieve Data from a User instance?Kinvey-Xamarin:如何从用户实例接收数据?
【发布时间】:2016-07-28 13:19:52
【问题描述】:

我现在正在处理 Kinvey 项目,但在从用户实例中读取用户名或特殊属性时遇到了一些问题。我首先尝试通过调用_User.UserName 以同样的方式获取_User.ID,但这并没有返回任何内容(但ID 确实很好奇)。我也在谷歌上搜索过,但没有任何关于它的文章。希望您能提供帮助,将不胜感激!

【问题讨论】:

    标签: xamarin kinvey


    【解决方案1】:

    对于特殊属性,使用User 类上的.Attributes 数组。 喜欢这段代码:

    Console.WriteLine ("custom attribute is: " + kinveyClient.User ().Attributes["myAttribute"]);
    

    对于用户名,请尝试.UserName(),但您似乎必须在填充此字段之前显式检索用户对象

    User retrieved;
    try {
        retrieved = await kinveyClient.User().RetrieveAsync();
    } catch (Exception e) {
        Console.WriteLine("{0} caught exception: ", e);
        retrieved = null;
    }
    Console.WriteLine ("logged in as: " + retrieved.Username );
    Console.WriteLine ("custom attribute is: " + retrieved.Attributes["myAttribute"]);
    

    文档:http://devcenter.kinvey.com/xamarin/guides/users#UserClass

    (答案适用于 SDK 版本 1.6.11)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      • 1970-01-01
      相关资源
      最近更新 更多