Вопрос

We have a web service that needs to indentify a user accross his devices, wp8, and win8.

On the phone side we have UserExtendedProperties.GetValue("ANID2"), which get's the anonymous microsoft id.

On Windows8 there's OnlineIdAuthenticator.AuthenticateUserAsync with UserIdentity.SafeCustomerId and other properties, though none of them look like the ANID2.

The OnlineIdAuthenticator api exists on phone, but throws NotImplementedException.

Is there any way to get a common user identifier on win8 and wp8?

Thanks

Это было полезно?

Решение

The best way I know (it's apparently the recommended way too) is to use Azure Mobile Services (http://www.windowsazure.com/en-us/home/scenarios/mobile-services/). There is a free plan that you can use. With Mobile Services you can use the MobileServiceClient (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.mobileservices.mobileserviceclient.aspx) to get a unique ID for each user (based on the MS account).

This code gets the user ID:

MobileServiceClient client = new MobileServiceClient(serviceUri);
MobileServiceUser user = await client.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);

/* The user ID contains the provider name and the ID seperated by a colon */
var userId = user.UserId.Split(':').Last();

You can find some more information here: http://msdn.microsoft.com/en-us/library/jj863454.aspx and the SDK here: http://www.windowsazure.com/en-us/develop/mobile/developer-tools/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top