PDA

View Full Version : <Help>Getting iPhone id




Moon013
Jul 14, 2008, 09:27 PM
Hi,
Currently I am trying to do a application that will ask if the user wanted to send his iPhone id to a server. If he want he will click a button, and it will lead to a function that will get his iPhone id, and then send it to a server.

I am not sure if this code gets the iPhone id:

NSString* deviceName;
deviceName = [[[UIDevice currentDevice] name] copy];

I could not test it currently as there are still some missing stuff.

In addition, I have absolute no idea how can i get the user location, not the ones with coordinates, but with countries names..is it possible?



Sbrocket
Jul 14, 2008, 10:46 PM
If you're trying to store unique data based on the device it is uploaded from, you don't want to use the name property.

[[UIDevice mainDevice] uniqueIdentifier] is what you want.

Moon013
Jul 14, 2008, 11:10 PM
Hey thanks for helping!

You have written "[UIDevice mainDevice]", why do we use the method mainDevice and not currentDevice?


I have a hard time finding the information regardlin UIDevice class, kind of unsure what it has and what i could provides...sorry about that...

Sbrocket
Jul 15, 2008, 01:16 AM
Hey thanks for helping!

You have written "[UIDevice mainDevice]", why do we use the method mainDevice and not currentDevice?


I have a hard time finding the information regardlin UIDevice class, kind of unsure what it has and what i could provides...sorry about that...

Methods have specific names. You can't just change them at will.

+[UIDevice mainDevice] (the + meaning its a class method) is how you access the singleton UIDevice object. Obviously there won't be more than one device, and mainDevice is how you access that one instance of UIDevice. As for "how you know" what the specific method, or property, or whatever is...that's why documentation exists.

Moon013
Jul 15, 2008, 02:51 AM
Thanks for the help :)

vavdiyaharesh
Nov 19, 2008, 09:55 PM
Hey but i m getting error like "UIDevice may not support to main Device" so wt should i write man???

jnic
Nov 20, 2008, 04:44 AM
[UIDevice currentDevice] is correct; docs here: https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/clm/UIDevice/currentDevice.

You still want uniqueIdentifier as Sbrocket said, so [[UIDevice currentDevice] uniqueIdentifier] will give you the user's ID.