我一直在使用下面的方法一个月左右没有问题。即使在卸载应用程序之后,设备ID仍保持不变。最近我注意到我的设备ID已更改。我最近在Xcode6上做了大量的应用程序构建。这可能是一个原因吗?我希望我知道它何时改变。它让我吃了一惊。当应用程序进入应用程序商店时,我有什么担心吗?也许这只是一个Xcode构建问题?我只是寻找一种简单的方法来保证唯一的设备ID。我会使用advertisingIdentifer,但我听说用于其他目的,广告将被应用商店拒绝。下面是代码:为什么我的唯一设备ID更改?
+ (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;
}
作为一个旁注:一BETT呃选择使用将是' - [UIDevice identifierForVendor]'。请参阅[文档](https://developer.apple.com/library/iOS/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/identifierForVendor)。 – ravron 2014-12-03 16:28:36
可能您已重新启动您的设备。 – holex 2014-12-03 16:41:21
@Riley据我所知,如果他们卸载我的所有应用程序,identifierForVendor将会改变。我不希望该ID在卸载我的应用程序时发生变化。 – user4233467 2014-12-03 19:43:56