Reputation: 902
I have an iPhone app that needs to send data (it's a vote) to a mySQL server. But the user is only allowed to vote once a day and only once per user. I connect to the mySQL server by sending an HTTP request to a PHP script.
What I need is some sort of unique identifier of the iPhone the user is using. I think it's OK if the user votes twice using two iPhones, so that isn't a big concern: the purpose of the identifier is to identify each iPhone.
How can I get this? I would use [[UIDevice currentDevice] uniqueIdentifier] but I have read it is now deprecated. I have read about an open source library but it seems to have privacy leaks.
Can you guys think of any way to do this, either via XCode or via PHP? I would just keep the hasVoted BOOL in the app, but then the user can just uninstall it and make it reset...
Upvotes: 0
Views: 284
Reputation: 13267
You can use CFUUIDCreate
to make a random, unique ID. Then save the ID. Do not use NSUserDefaults
since it is deleted if the user reinstalls the app. I would save it in the keychain. This is not deleted unless the iPhone is wiped, and the user cannot modify the keychain.
Upvotes: 2