locked
Unable to get first and last name using UserInformation class in Windows 8.1 RRS feed

  • Question

  • Hi,

    we have developed an app to get first and last name of the logged in user using the below code. but, if we open the app in Windows 8.1 we are not able to get the first and last name. please advice us.

    private async void GetFirstNameButton_Click(object sender, RoutedEventArgs e)
            {
                string firstName = await UserInformation.GetFirstNameAsync();
                if (string.IsNullOrEmpty(firstName))
                {
                    rootPage.NotifyUser("No First Name was returned", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("First Name = " + firstName, NotifyType.StatusMessage);
                }
            }

    Thanks in Advance

    Monday, February 3, 2014 10:21 AM

Answers

  • its possible to prevent apps access to those names from the windows settings. in your app first check
    UserInformation.NameAccessAllowed
     to see if you have access

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, February 3, 2014 1:18 PM

All replies

  • According to the description in the Account Picture Name Sample, the first name and last name of the user can only be retrieved for a user that is logged on with a Microsoft account. If empty strings are returned you should fallback to DisplayName.
    Monday, February 3, 2014 11:13 AM
  • Hi,

    the logged in user here is Microsoft account only. but still we are not able to pull in the first name and last name in windows 8.1

    Monday, February 3, 2014 12:51 PM
  • its possible to prevent apps access to those names from the windows settings. in your app first check
    UserInformation.NameAccessAllowed
     to see if you have access

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, February 3, 2014 1:18 PM
  • Thanks Dave. Yes, as you said we have problem with the Windows Settings. we have enabled the Privacy settings of PC then it worked with the same code in both Windows 8 and 8.1 as well.
    Monday, February 3, 2014 1:24 PM