I'm developing an application for UWP (Universal Windows Platform) with availability on Windows 10 and Xbox One devices. The app is a single user application. I'm trying to determine at runtime a unique identifier for the active signed-in user -- just an ID without any personally identifiable information. The documentation for the StoreContext class suggests that I should be able to determine this by examining the User
property on the default StoreContext
object; specifically, the NonRoamableId
property seems appropriate. However, in every context I've run the app in (debug, deployed, Windows, Xbox), the StoreContext's User
property has always been null
. Is this expected? I'm unable to find any other way to determine this information.
Of note: I'm aware of the UserWatcher class and its methods for querying users on the system. However, I would like to avoid using this for the following reasons:
User
is the one associated with the current StoreContext
, meaning that such a solution would be error-prone.I'm developing against the Windows 10 Creators' Update SDK (10.0.15063).
This looks like it may have been a UWP bug that is now fixed. With no code changes, I now see a non-null User
object attached to the LaunchActivatedEventArgs
on app launch. Accepted the answer accordingly.
Active user signed in with MS account can be obtained from the OnLaunched/Activated event arguments.
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Windows.System.User active_user = e.User;
}
This requires adding User Account Information capability in package manifest.