I am showcasing content in my iOS app and I would like users to be able to vote. Instead of implementing a complicated “register a username” functionality, I just want a user to be able to upvote.
In the World of web development I could prevent duplicate votes by using the IP address of the client.
How can I make a simple voting system that allows a user to be only able to vote up a post once and not worry about duplicates?
Dont use
uniqueIdentifieras Apple has stated:Instead, I would suggest changing over from
uniqueIdentifierto this open source library (2 simple categories really). It utilizes the device’s MAC Address along with the App Bundle Identifier to generate a unique ID in your applications that can be used as a UDID replacement.Keep in mind that unlike the UDID this number will be different for every app.
You simply need to import the included
NSStringandUIDevicecategories and call:You can find it on Github here:
https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
Heres the code (just the .m files – check the github project for the headers):
UIDevice+IdentifierAddition.m
NSString+MD5Addition.m: