stefanosn
stefanosn

Reputation: 3324

Question about iphone app, unique identify the user on external database

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.

Upvotes: 0

Views: 338

Answers (3)

Jason McCreary
Jason McCreary

Reputation: 73021

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.

Upvotes: 0

Srikar Doddi
Srikar Doddi

Reputation: 15599

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.

Upvotes: 0

esqew
esqew

Reputation: 44714

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

Upvotes: 2

Related Questions