I have been using the following method for around a month with no problem. The device ID remained the same even after uninstalls of the app. Recently I noticed that my device ID changed. I have been doing a lot of builds of the app recently on Xcode6. Could this be a cause? I wish I knew exactly when it changed. It caught me by surprise. Do I have anything to worry about when the app goes on the app store? Maybe this is just an Xcode build problem? I am just looking for a simple way to guarantee a unique device ID. I would use advertisingIdentifer but I hear using it for purpose other then advertisements will get rejected by app store. Here is the code:
+ (NSString *)getUserID
{
NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString *retrieveuuid = [SSKeychain passwordForService:Appname account:@"user"];
if(retrieveuuid == NULL)
{
CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
retrieveuuid = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
CFRelease(newUniqueId);
[SSKeychain setPassword:retrieveuuid forService:Appname account:@"user"];
}
NSLog(@"%@", retrieveuuid);
return retrieveuuid;
}