简体   繁体   中英

How can i get user Device Id in iOS?

我想要用户移动设备ID bcz我想在提交表单时将其存储在数据库中,这样每当用户卸载应用程序并再次重新安装时,他将获得之前提交的所有记录,因此他不需要再次提交数据。我使用了库但它将为所有device.please help返回相同的id。提前谢谢。

Official Documentation answer

@property(nonatomic, readonly, retain) NSUUID *identifierForVendor

NSString *identifier = [[UIDevice currentDevice].identifierForVendor UUIDString];

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

Normally, the vendor is determined by data provided by the App Store. 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.

If the value is nil, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device.

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. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.

您可以使用唯一的设备ID FOR IOS6 +

NSString *identifier = [[UIDevice currentDevice].identifierForVendor UUIDString];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM