In my current application,i have to let user to login from different iOS devices to their account. Currently i\'m doing user authentication from a token value. but in order
As you already know this using the device's UUID isn't allowed, however, you can generate your own UUID and store it on the devices' UserDefaults.
using the identifierForVendor isn't 100% reliable, as it only works on iOS6 and above, and users have the ability to opt-out of giving it to you, which makes it a bad choice.
Here's some code I copied of the internets sometime ago and still use it till today, will try to find the source and update my answer in a bit. EDIT: Source
This will generate and store a UUID for you in UserDefaults:
- (NSString *)createUUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
[[NSUserDefaults standardUserDefaults] setObject:(__bridge NSString *)string forKey:@"UUID"];
[[NSUSerDefaults standardUserDefaults] synchronize];
return (__bridge NSString *)string;
}
And whenever you need to read the generated UUID:
- (NSString*)UUID
{
return [[NSUserDefaults standardUserDefaults] ObjectForKey:@"UUID"];
}
Now you have the choice to append your own user's ID to that too so you'll be able to know what UUID is linked to which user..
This is just a rough sketch of how it should work