23 avril 2024

Identifier un utilisateur sur winRT

Comment savoir si l’utilisateur de votre application est sur une tablette (processeur ARM) ou sur un PC Windows 8 ? Pas de Windows Live anonymus comme sur Windows Phone (voir mon article précédent).

La seule solution que j’ai trouvé pour le moment afin d’identifier un utilisateur est d’identifier, et bien, le matos via hardwareidentification celle-ci :

 
Windows.System.Profile.HardwareToken higp;
higp = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);

IBuffer hardwareId = packageSpecificToken.Id;
IBuffer signature = packageSpecificToken.Signature;
IBuffer certificate = packageSpecificToken.Certificate;

var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var array = new byte[hardwareId.Length]; dataReader.ReadBytes(array);

System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (var i = 0; i < array.Length; i++)
{
    sb.Append(array[i].ToString());
}
string UserID = sb.ToString();


Ca vous retourne une chaine du type :
4013860802242465091044601040178594017959401501134072018810968320130269014493