同一设备中的不同 UUID。

Different UUID in same device.

我在同一台设备上 运行 个具有相同 API 的不同应用程序。但是不同的 UUID 去服务器。如何使用相同的设备和 API 向两个应用程序发送相同的 UUID。我该如何解决这个问题。我想在具有不同应用程序的同一设备中使用相同的 UUID。

这里有不同的 UUI:- 1: 0D0B5F8F-9D4D-44E6-ACA2-DF9DA634FA53 2: 738927AD-C795-4C4C-9D41-AB0FCD7357E1

let imei = UIDevice.current.identifierForVendor?.uuidString
Print(imei)

以下是 identifierForVendor 文档中的一些有用摘录:

  1. If the app was not installed from the app store (such as enterprise apps and apps still in development), then a vendor identifier is calculated based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format.

    On iOS 6, the first two components of the bundle ID are used to generate the vendor ID. if the bundle ID only has a single component, then the entire bundle ID is used.

    On IOS 7, all components of the bundle except for the last component are used to generate the vendor ID. If the bundle ID only has a single component, then the entire bundle ID is used.

例如,给定包 ID com.example.app.app1,在 iOS 7.x+ com.example.app 将用于计算供应商 ID(仅省略最后一个组件)。由于您的目标可能是 iOS 7+,因此请确保您的应用程序的捆绑包标识符仅在最后一个组件中有所不同。

  1. 要记住的另一件事是:

    The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.

当您重新安装应用程序时,UIDevice.current.identifierForVendor?.uuidString 提供的 ID 会发生变化。

您可以使用 设备检查 API 在 iOS 11 中引入,如果您想要识别用户的设备,即使用户重新安装了您的应用程序。

您的服务器可以在苹果设备上使用生成的令牌。有关详细信息,请参阅以下文档

https://developer.apple.com/documentation/devicecheck/dcdevice/2902276-generatetoken