Nav Link On

iPhone Dev Forums > General Development > SDK Coding Help > Unique identifier for the iPhone

Reply

 

LinkBack Thread Tools Display Modes
Old 06-24-2008, 03:32 PM   #1 (permalink)
Junior Member
Default Avatar
 
Join Date: Jun 2008
Location: Netherlands, Bodegraven
Posts: 6
Default Unique identifier for the iPhone

Hi, im writing an app that should run on several iPhones. At some point the app connects to a webserver. Is there some unique id that i can use to identify which iPhone is doing the request. For example the serial number or imei number?

Does anyone kwow how to retreive these id's using the SDK?
ideveloper is offline   Reply With Quote
Old 06-24-2008, 03:41 PM   #2 (permalink)
Administrator
 
MacTyler's Avatar
 
Join Date: Mar 2008
Posts: 165
Smile

from this thread over on ipodtouchfans

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:

You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor.

@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:

You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor.

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!
MacTyler is offline   Reply With Quote
Old 06-24-2008, 04:56 PM   #3 (permalink)
Junior Member
Default Avatar
 
Join Date: Jun 2008
Location: Netherlands, Bodegraven
Posts: 6
Default

Thanks, for the quick response. Your code certainly helps.

For now i will just use the code below to generate a unique identifier.

NSString* strId = [[UIDevice currentDevice] uniqueIdentifier];
ideveloper is offline   Reply With Quote
Old 12-08-2008, 06:16 PM   #4 (permalink)
Junior Member
Default Avatar
 
Join Date: Dec 2008
Posts: 1
Default Unique Identifier for the iPhone

Hi MacTyler,

IOKit is NOT available on iPhone. Is there any other way to retrieve the serial number???

Thanks
dtuser is offline   Reply With Quote
Reply

iPhone Dev Forums > General Development > SDK Coding Help


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC1