Get UDID in iOS 8 +

I need to get the UDID of my iPhone to use in my iOS app.

Some info about my app:

  • My app is not for the public and will never make it to the store , so I can use any 3rd party libraries. It will only be used by some employees at work.

  • My device will always be plugged into a Mac, while my app is running.

  • The way I see it, there are only 2 ways this can be accomplished.

  • Use a third party library to get the UDID inside of my iOS app.
  • Since the iPhone will always be plugged into a Mac while my app is running, how about getting the UDID via the Mac and transferring it in some way to my app in the iPhone.
  • Any ideas would be appreciated. Thanks.

    Edit: Question is, do you know any 3rd party libraries or a better way to get my app to automatically get the iPhone's UDID while running?

    Edit 2: I know this can be done using only my phone because of this web app: http://get.udid.io/

    How does this work?


    If you're trying to read the UDID to automate something on the Mac, then you can use something like system_profiler SPUSBDataType to get the UDID, for my phone the entry:

              Product ID: 0x12a8
              Vendor ID: 0x05ac  (Apple Inc.)
              Version: 7.01
              Serial Number: 7bed*********************************33
              Speed: Up to 480 Mb/sec
              Manufacturer: Apple Inc.
              Location ID: 0x1d110000 / 6
              Current Available (mA): 500
              Current Required (mA): 500
              Extra Operating Current (mA): 1600
    

    The line Serial Number is the UDID (I've starred it out as I'm stupidly paranoid).

    Note, that without the UDID you could never have got the app onto the phone in the first place.

    You could run a small daemon process on the mac, reading this information and creating a bonjour service that provides the information to requestors - it's a SMOP.


    It's very simple. Go to Xcode Window and select Devices or you can find it in Organizer. 在这里输入图像描述

    http://www.raywenderlich.com/2915/ios-code-signing-under-the-hood/organizerudid


    From a quick look online, it looks like you can use a private framework called libMobileGestalt.dylib.

    After linking the library and importing the header, you should be able to do something like this (reference):

    CFStringRef value = MGCopyAnswer(kMGUniqueDeviceID);
    NSLog(@"Value: %@", value);
    CFRelease(value);
    

    On my Mac, I can find that particular dylib here:

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libMobileGestalt.dylib
    
    链接地址: http://www.djcxy.com/p/25356.html

    上一篇: python中的金融技术分析

    下一篇: 在iOS 8 +中获取UDID