Check if the user is logged in or not after the OnlineIdConnectedStateChange mode is started

I am working on a Windows 8.1 Metro application. The application provides a personal experience to a user who is logged on to Windows with his Live account.

As provided in Windows, any user can connect / disconnect their active account on a PC using the PC settings β†’ Account. My request should be notified of this event, that is, whenever a user connects / disconnects their personal account on a PC. Now, according to the MSDN page ( http://msdn.microsoft.com/en-us/library/windows/apps/hh977056.aspx ), this event will call the OnlineIdConnectedStateChange function. I was able to complete the background task in an application that listens for the trigger and it works fine. Each time a change occurs in the connected Live account when the event listener starts. But I can’t determine the fact that the user is logged in with some Live account or logged out of an already connected account.

I tried using Windows.Security.Authentication.OnlineId.OnlineIdAuthenticator , as mentioned in ( Metro App - How to Detect If You Logged In Using a Live ID or Local Account ), but this causes an authentication flow if no user is logged in . This is not what I want. I just want to know that someone is logged in or not. I do not want to start the Auth stream.

Is there a way to determine the user's login / logout status when the "OnlineIdConnectedStateChange" event is fired in a background job?

Thanks for any help.

+7
c # live-connect-sdk
source share
1 answer

You can always save the last user of the user who successfully logged in. Then compare this identifier with the current userId, if it is zero, then the user will log out, if not the new user.

Edit:

  • The user opens the application. 1.a: User logs in => stores some flag or userId (mainly information) 1.b: User logs in => stores some flag null or null userId

  • User closes the application

  • The background worker selects an event based on a flag or information that you can determine if the user is logged in or logged out.

Depending on what you are storing, you can use AppSettings or IsolStorage among other options for storing the flag.

+3
source share

All Articles