tags:

views:

50

answers:

3

Hi everyone what i am trying to do is the following: i have an app that gives the ability to the user to post a message to an external database. This ability i want to be available only one time. The second time, the user wont be able to post a message. I want to find a way to achieve this even if the app has been removed from the iphone. I want somehow to uniquely identify every time from my app the user's iphone device and save this unique value to my external database.

I have found this:

UIDevice *device = [UIDevice currentDevice];
NSString *uniqueIdentifier = [device uniqueIdentifier];

Is this code going to give me a unique identifier for each users device (even if the app has been removed then installed again) so i can save this to my external database and the next time the user posts check if it exists already the unique id? If it exists i would know that this is the second time that posts.

+1  A: 

Yes, [[UIDevice currentDevice] uniqueIdentifier] is unique on all devices, it's also known as the UDID.

esqew
A: 

Yes, the UDID is for the device. It will not change between app downloads. The only time this will change is between devices.

Note that it is relatively common for a user to upgrade their device (new phone) - therefore changing their UDID. So, you should consider if this is acceptable.

Jason McCreary
Jason you confused me...The UDID changes when the user updates its device or it changes when it buys a new device?
stefanosn
Sorry, new device. I meant *upgrades* which is a common thing in the iPhone world. I edited my answer.
Jason McCreary
A: 

You are not handling the case where a user can change his device and use a different device to install the app and send the message. You are better off handling this by Marking off this user when he sends the message first time. It is your database so you know the user.

CodeToGlory