Search code examples
ios7jailbreakcydiaiokit

Get device serial number on iOS 7


With iOS device IOKit extensions I was able to get the serial number of the device. In iOS 7 IOKit binary is not on IOKit folder. Is there any other way to get the serial number? I want to use it on jailbroken device, Cydia can show serial number if we open it, but I didn't find other way than IOKit.


Solution

  • You can get it using MobileGestalt Library in your makefile

    xxx_LIBRARIES = MobileGestalt

    then declare:

    OBJC_EXTERN CFStringRef MGCopyAnswer(CFStringRef key) WEAK_IMPORT_ATTRIBUTE;
    

    in your Header file

    then for getting the serial number you have to use :

    CFStringRef SNumber = MGCopyAnswer(CFSTR("SerialNumber"));
    NSLog (@"Serial Number : %@", SNumber);
    

    if you mean UDID you have to use :

    CFStringRef UDNumber = MGCopyAnswer(CFSTR("UniqueDeviceID"));
    NSLog (@"UniqueDeviceID : %@", UDNumber);