Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

identify user accross WP8 and Win8: ANID2 vs SafeCustomerId

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

like image 924
sharp johnny Avatar asked Nov 28 '25 03:11

sharp johnny


1 Answers

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/

like image 177
calum Avatar answered Nov 30 '25 19:11

calum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!