2016-07-28 18 views
0

我正在開發一個Kinvey項目,並且在閱讀User實例的用戶名或特殊屬性時遇到了一些問題。我第一次試圖通過調用_User.UserName獲得_User.ID,但這沒有返回任何東西(但ID確實好奇)。我也在Google上搜索過,但沒有任何關於它的文章。希望你能幫助,將不勝感激!Kinvey-Xamarin:如何從用戶實例接收數據?

回答

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)

0

Zhyano,

如果你使用這個ID用戶發現,它得到正確的用戶與記錄的公共屬性一起?

感謝, Pranav Kinvey支持