Search code examples
c#ioswindowsvisual-studioudid

How to read a UDID of the connected iOS device on Windows using C#?


Could you please suggest how to get a UDID of the connected iOS device using C# on Windows? I tried to search in Google, but didn't find anything. Is there a way or a workaround for this? Maybe any open-source library or something else?

Please suggest.

Thanks in advance.


Solution

  • Here's the problem, UDIDs have been locked down since IOS 7, you shouldn't access this ID within your code. There are ways to extract the id through background web pages that are invisible, but this will only work if you DON'T plan to distibute your app on the iTunes store, since your app will be rejected.

    In 2013, Mattt on his blog, NSHipster (http://nshipster.com/uuid-udid-unique-identifier/), wrote the following:

    As of May 1st, Apple began enforcing this deprecation on all new app submissions, even for apps targeting earlier versions of iOS. Any use of uniqueIdentifier is grounds for immediate rejection of new binaries.

    (read the rest of Mattt's blog entry should you wish for a more detailed explanation, of the ins and outs of the this change)

    What you can do about this? Nothing. However, if you need an ID of sorts to do whatever you are trying to do then you have two options:

    identifierForVendor

    here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor

    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.

    advertisingIdentifier

    here: https://developer.apple.com/library/ios/documentation/AdSupport/Reference/ASIdentifierManager_Ref/index.html#//apple_ref/occ/instp/ASIdentifierManager/advertisingIdentifier

    Unlike the identifierForVendor property of the UIDevice, the same value is returned to all vendors. This identifier may change—for example, if the user erases the device—so you should not cache it.

    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.