Return the Serial Number!

Discussion in 'iOS Development' started by gojohnnyboi, Jun 6, 2008.

  1. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Guys, with a little research, i found out how to return the serial number of the iphone/ipod touch!

    Here's a function straight out of my code library.


    Code:
    @interface AppLib : NSObject
    ...
    
    
    
    @implementation AppLib
    
    - (NSString*)getSerialNumber
    {
    	CFTypeRef serialNumberAsCFString;
    
    	io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
    
    	if (platformExpert)
    		{
    			serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
    		}
    
    	IOObjectRelease(platformExpert);
    
    	NSString *serial = [[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];
    	
    	return serial;
    }

    Now in my app i can just call:

    Code:
    AppLib* lib = [[AppLib alloc] init]
    
    // say i make an alertsheet...
    
    [sheet setBodyText:[lib getSerialNumber];
    and that's how to get the serial number! Hope this helps!

    -John

    P.S. > Don't for get to add "-framework IOKit" to your makefile!
  2. SimonTheSnowman

    SimonTheSnowman Active Member

    Joined:
    Dec 29, 2007
    Messages:
    1,066
    Likes Received:
    10
  3. Hiratai

    Hiratai Banned

    Joined:
    Dec 2, 2007
    Messages:
    2,421
    Likes Received:
    42
    Device:
    iPhone 4 (Black)
    Or go into Settings.
  4. awal

    awal Well-Known Member

    Joined:
    Jan 2, 2008
    Messages:
    4,764
    Likes Received:
    31
    Device:
    iPhone 4S (White)
    Or connect to iTunes and see it there......
  5. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Why not use that organ within your skull and realize that this is the application development section, and the reason you would do this is for an APP. an app cant look at the back of the ipod, and some developers make their apps check the serial number to check if the device has donated/registered, like Kate or Pool.
  6. Chucky102

    Chucky102 Well-Known Member

    Joined:
    Nov 23, 2007
    Messages:
    3,555
    Likes Received:
    66
    Device:
    iPhone 5 (Black)
    I have to agree with the above posters...back of the ipod, itunes, and settings. I don't find this useful.
  7. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55

    Again, an app cant look in itunes or go to settings.... this is for application developers, hence the placement of this thread.

    Please, do not flame here, or disrespect me, because many people were looking for this information i know for a fact, and maybe you people should learn objective-c and see how hard it is to figure things like this out. Thanks.
  8. Chucky102

    Chucky102 Well-Known Member

    Joined:
    Nov 23, 2007
    Messages:
    3,555
    Likes Received:
    66
    Device:
    iPhone 5 (Black)
    I think you need to calm down, you're just 12...to my understanding (kidding). Don't think just because you know a programing language you're better. And I bet you'll say something like "I'm not showing it off", but looking at your post "This is for APPLICATION DEVELOPERS" and "YOU PEOPLE SHOULD LEARN OBJECTIVE-C....HARD"....Just my two cents, still seems useless.

    Please Register or Log in to view images

  9. awal

    awal Well-Known Member

    Joined:
    Jan 2, 2008
    Messages:
    4,764
    Likes Received:
    31
    Device:
    iPhone 4S (White)
    Ah, I apologize, in that case, nice find.
  10. SimonTheSnowman

    SimonTheSnowman Active Member

    Joined:
    Dec 29, 2007
    Messages:
    1,066
    Likes Received:
    10
    lol this app is useless in my prospective... you can just look at the back of the ipod, go in settings, or connect to itunes

    Please Register or Log in to view images



    why would you open an app and see the serial number... when you can just go into settings> general...

    Pointless to me..

Share This Page