Windows Universal - How to check if user is signed into Microsoft Account?

353 Views Asked by At

Is there an accepted way to tell if a user is logged into a Windows Universal App with a Microsoft Account as opposed to a Local Account?

I'm trying to implement in-app-purchases and I've hit a snag if CurrentApp::GetUnfulfilledConsumables() is called from a Local Account. An exception gets thrown with the message "The specific account does not exist."

A few people on the web are using the Live SDK to try to initialize the user's credentials, which would fail for non-Microsoft accounts. And in this way they have a roundabout way of figuring out if the user is logged in. (https://social.msdn.microsoft.com/Forums/en-US/f6946851-b495-45f6-95a4-eb3c2a004c0e/live-sdk-v53-how-to-tell-the-difference-between-a-user-logged-in-with-a-microsoft-account-and?forum=messengerconnect)

But I was wondering if there was a nicer, cleaner way to detect if a user is logged into a Microsoft Account or a Local account without having to integrate an entire SDK just for one function call.

Thanks for your help.

1

There are 1 best solutions below

3
On BEST ANSWER

Unfortunately, the answer is that you need to put the call inside a try ... catch to catch the exception and then look at the exception->HResult to confirm that it's the "The specific account doesn't exist" exception. (And rethrow anything else.)