سؤال

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.

هل كانت مفيدة؟

المحلول 2

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);

نصائح أخرى

Cydia is open source http://gitweb.saurik.com/cydia.git . Here is how it's done in it

static NSString *UniqueIdentifier(UIDevice *device = nil) {
    if (kCFCoreFoundationVersionNumber < 800) // iOS 7.x
        return [device ?: [UIDevice currentDevice] uniqueIdentifier];
    else
        return [(id)$MGCopyAnswer(CFSTR("UniqueDeviceID")) autorelease];
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top