我可以获取用户的唯一标识符吗?我想跨设备同步用户数据。 [英] Can I get the user's unique identifier? I want to synchronize user data across devices.

查看:119
本文介绍了我可以获取用户的唯一标识符吗?我想跨设备同步用户数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于Windows应用商店应用:

我可以获取用户的唯一标识符吗?

我希望跨设备同步用户数据。
About Windows Store App:
Can I get the user's unique identifier?
I want to synchronize user data across devices.

推荐答案

你好,

欢迎
到开发通用Windows应用论坛!

请阅读粘贴帖子,尤其是

发布指南:主题行标签

Windows 10 SDK和工具的已知问题 
 请记得添加标签自己标题。

Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools  and please remember to add tag to title by yourself.

在UWP中,
SystemIdentification类
将是您想要的。你可以参考
Peter Torr - MSFT
关于SO的回答:在Windows 10周年更新中如何获得
获取唯一设备ID

In UWP, the SystemIdentification Class would be that you want. You could refer to Peter Torr - MSFT’s answer on SO:How to get unique Device IDs on Windows 10 Anniversary Update

以下是Peter Torr的原始回复:

The following is Peter Torr's original reply:


Windows 10周年更新推出了新的  SystemIdentification  类型 其中
完全符合您的要求。它比旧的ASHWID有几个好处:

The Windows 10 Anniversary Update introduced the new SystemIdentification type which does exactly what you want. It has several benefits over the old ASHWID:


  • 它适用于所有Windows 10平台

    • 注意:ASHWID现在也适用于所有平台,但仍有上面列出的其他缺点

    • 注意:这对于企业方案最有用;如果没有
      a非常好的理由,您不太可能拥有使用此功能的Windows应用程序批准的应用程序,因为它代表隐私问题


    API有一个小缺点:它不适用于某些旧PC,因为它需要UEFI或TPM。过去5年以上制造的大多数PC都应该有这种硬件,所有其他非PC设备(手机,Xbox,HoloLens等)都有正确的硬件。
    如果找到没有PC的PC硬件,您将需要回退到ASHWID或其他一些机制。

    There is one minor drawback to the API: it won't work on some old PCs, since it requires either UEFI or a TPM. Most PCs built in the last 5+ years should have this hardware, and all other non-PC devices (phone, Xbox, HoloLens, etc.) have the correct hardware. If you find a PC that doesn't have the hardware, you will need to fall back to the ASHWID or some other mechanism.


    使用API​​很简单;不需要复杂的解析或计算后端的漂移:

    Using the API is simple; there is no need for complex parsing or accounting for drift on the back-end:

    using Windows.System.Profile;
    
    IBuffer GetSystemId()
    {
      // This sample gets the publisher ID which is the same for all apps
      // by this publisher on this device.
      // Use GetSystemIdForUser if you have the userSystemId capability
      // and need the same ID across all apps for this user (not 
      // really applicable for apps in the Windows Store)
      var systemId = SystemIdentification.GetSystemIdForPublisher();
    
      // Make sure this device can generate the IDs
      if (systemId.Source != SystemIdentificationSource.None)
      {
        // The Id property has a buffer with the unique ID
        return systemId.Id;
      }
    
      // This is a very old PC without the correct hardware. Use 
      // another mechanism to generate an ID (or perhaps just give 
      // up due to the small number of people that won't have the ID; 
      // depends on your business needs).
      return GetIdFromAshwidOrSomethingElse();
    }



    如问题中所述,  此ID应该仅用于后端服务中的相关性目的(例如,用于遥测,广告,使用度量等)。它永远不应该用于创建匿名
    用户帐户,识别或跟踪用户,加密用户数据等。
    这是因为不同的用户可以共享同一设备,或者同一个用户可以漫游不同的设备,因此ID不会与用户或他们的数据进行1:1的映射。

    As noted in the question, this ID should only be used for purposes of correlation in a back-end service (eg, for telemetry, advertising, usage metrics, etc.). It should never be used to create anonymous user accounts, to identify or track users, to encrypt user data, etc. This is because different users can share the same device, or the same user can roam across different devices, so the ID doesn't map 1:1 with a user or their data.


    此API可在Universal API Contract v3中找到,可在Windows Universal SDK 10.0版中找到.14393.0(请记住,如果您正在进行多版本应用,并希望点亮此API的使用,则应该&bbsp;执行
    运行时版本检查;相反,您应该只是  查询
    操作系统以查看API是否可用


    最好的问候,

    Best Regards,


    Xavier Eoro

    Xavier Eoro

    注意:此响应包含对第三方万维网站点的引用。微软提供此信息是为了方便您。微软不控制这些站点
    并且没有测试任何在这些网站上找到的软件或信息;因此,Microsoft不能就其中发现的任何软件或信息的质量,安全性或适用性做出任何陈述。使用互联网上的任何
    软件存在固有的危险,并且Microsoft提醒您在从Internet检索任何软件之前确保您完全了解风险。

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    这篇关于我可以获取用户的唯一标识符吗?我想跨设备同步用户数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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