在 Windows Phone 8 下获取唯一设备 ID (UDID) [英] Get Unique Device ID (UDID) under Windows Phone 8

查看:26
本文介绍了在 Windows Phone 8 下获取唯一设备 ID (UDID)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何唯一的设备 ID (UDID) 或任何我可以在 Windows Phone 8 (WP8) 上读出的类似 ID 不会随着硬件更改、应用程序重新安装等而改变?

Is there any unique device ID (UDID) or any similar ID I can read out on Windows Phone 8 (WP8) that doesn't change with hardware changes, app-reinstallation etc.?

在较旧的 Windows Phone 版本中,有这样的 ID:WP7:Windows Phone 的设备状态

In older Windows Phone versions there were such IDs: WP7: Device Status for Windows Phone

WP7.1:DeviceStatus 类

但它们不再适用于 SDK 8.0.

But they doesn't work anymore with SDK 8.0.

我为什么问:这个想法是用户在应用程序的第一次启动时获得一些免费积分,我想避免用户只是重新安装应用程序以获得新的免费积分.使用电子邮件或电话号码注册可以解决这个问题,但如果可以,我不想在第一次注册时打扰用户.

Why I ask: The idea is that a user gets some free credits with the first start of the the app and I want to avoid that the user just re-installs the app for getting new free credits. A registration with email or phone number could solve this, but if I can, I don't want do bother users at the first start with a registration.

---///---解决方案-----------

---///---SOLUTION----------

我可以确认 DeviceExtendedProperties.GetValue("DeviceUniqueId") 在 WP 8.0 中仍然有效.当我阅读以下文字时有点困惑:

I can confirm that DeviceExtendedProperties.GetValue("DeviceUniqueId") still works in WP 8.0. Got a little bit confused when I read the following text:

在 Windows Phone OS 7.0 中,此类用于查询特定于设备的特性.在 Windows Phone OS 7.1 中,大多数属性在DeviceExtendedProperties 已弃用,新的​​ DeviceStatus应该使用类来代替.但是,在适当的情况下,您可以仍然使用以下任何未弃用的属性.

In Windows Phone OS 7.0, this class was used to query device-specific properties. In Windows Phone OS 7.1, most of the properties in DeviceExtendedProperties were deprecated, and the new DeviceStatus class should be used instead. However, where appropriate, you can still use any of the below properties that are not deprecated.

MSDN:DeviceExtendedProperties 类

我可以运行以下代码,删除应用程序并重新安装并获得相同的 ID:

I can run the following code, delete the app and re-install it and get the same ID:

byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string DeviceIDAsString = Convert.ToBase64String(myDeviceID);
MessageBox.Show(DeviceIDAsString);

推荐答案

我还没有开始为 Windows Phone 8 开发,还在 7 上,但是你应该仍然可以使用原来的 DeviceExtendedProperties 类以拉回设备唯一性身份证.

I haven't yet started to develop for Windows Phone 8, still on 7, but you still should be able to use the original DeviceExtendedProperties class to pull back the Device Unique ID.

DeviceExtendedProperties.GetValue("DeviceUniqueId")

这篇关于在 Windows Phone 8 下获取唯一设备 ID (UDID)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆