none
[uwp] User. GetPropertyAsync(KnownUserProperties.DisplayName) returns empty string RRS feed

  • Question

  • I am upgrading a Win8 app to a Win10 uwp app.  I understand that UserInformation.GetDisplayNameAsync() and UserInformation.GetAccountPicture() have been deprecated in Win10.  So I looked at the sample app UserInfo in the Windows-universal-samples-master collection.  This sample app has code to retrieve the user information and the user picture (both of which the app I am trying to upgrade use).  However, the returned DisplayName is an empty string.  The user.GetPropertiesAsync call does return the user’s first and last name, but nothing else.  In addition, the returned picture is a generic picture, not the user’s account picture. 

     

    The application’s Package.appxmanifest does have User Account Information checked under the Capabilities tab, and I did answer yes when prompted if I want to allow the app to access user information.   

     

    Is there a problem with the sample app, or am I missing something?  Does anyone have a working sample?

     

    Thanks in advance for any help.

    jrstem

    Thursday, September 10, 2015 11:53 AM

All replies

  • Hello jrstem,

    I don’t think the sample is not right or you’ve done anything wrong. The problem is pending on the API: UserInformation.GetDisplayNameAsync()

    I have a remote VM and I use domain user to access the VM, then I get null when GetDisplayNameAsync.

    But if I use the same domain account on another Server and I can the DisplayName as Barry Wang:

    So may I know more details about your account? Is it a domain account or local account? Are you running on a VM?

    Maybe like the sample showed:

    // Choose a generic name if we do not have access to the actual name.

    We are not able to access the actual name in our environment.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 11, 2015 7:25 AM
  • Hi Barry,

     

    Thanks for the response. I do appreciate it.

     

    My account is a local account, not a domain account.  That being said, it is a Microsoft account, not a local account in the sense it is defined just on one PC.  I also expect that most of my customers will not be running a domain account.  No, I am not running on a VM, just vanilla Windows 10. 

     

    Here is a screenshot from the sample app showing what is and is not returned.

    As far as choosing a generic name is concerned, I can construct the user’s name from the firstName and lastName that is return (apparently correctly).  However, that still leaves the issue of the user’s account picture.  The application that I am converting displays both the user’s name and picture.  This information was available using UserInformation.GetDisplayNameAsync() and UserInformation.GetAccountPicture(), but since they have been deprecated (and obviously no longer work) I was looking for another way to retrieve the information.  I would hate to have to remove this information from the application – the users seem to like it.  I have already had a few customers email me and ask how they can get their picture back. 

     

    I have noticed that several MS core apps (weather, news, money, etc.) do display the account picture in the menu bar on the left side of their window.  Do you know if they using this API another function to get this information?

     

    Thanks again and best regards,

    jrstem

    Friday, September 11, 2015 9:01 AM
  • Hi there,

    I also have the same issue with UserInformation.GetAccountPicture() here.

    I use a local account in my PC without connecting to Microsoft account. I can get the DisplayName correctly. But I can't get my account picture. The method GetAccountPicture returns a generic picture like jrstem.

    Here is a my screenshot from the sample app:

    Regards,

    Jay

    Friday, September 11, 2015 9:23 AM
  • Hi Barry,

    I have created sample for getting user Display name, FirstName, LastName, Domain.

    I have added capability in Manifest file. I have created an appx. I have deplyed in two machines.

    Machine 1: System asked permission when API called. After clicking on "Yes" button I got All the values.

    Machine 2: System didn't shown permission alert, and I got only empty strings.

    I have seen "Account Info" privacy disabled in Machine 2. I have no clue, why it is turned it off by default.

    Please help us to find the issue in Machine 2.

    Thanks,


    Pallam Madhukar Windows Phone Developer

    Monday, June 25, 2018 9:58 AM