xcode 为什么我的唯一设备 ID 发生了变化?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27276645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why did my unique device ID change?
提问by user4233467
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:
我一直在使用以下方法大约一个月没有问题。即使卸载应用程序后,设备 ID 仍保持不变。最近我注意到我的设备 ID 发生了变化。我最近在 Xcode6 上做了很多应用程序的构建。这可能是一个原因吗?我希望我知道它什么时候改变。这让我很意外。当应用程序在应用程序商店上架时,我有什么可担心的吗?也许这只是 Xcode 构建问题?我只是在寻找一种简单的方法来保证唯一的设备 ID。我会使用 adsIdentifer,但我听说将其用于其他目的,否则广告将被应用商店拒绝。这是代码:
+ (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;
}
回答by JSA986
The unique device id does not persist This has been asked many times before and you should find some good info on here. A quick Google search brings up the following.
唯一的设备 id 不持久 这之前已经被问过很多次了,你应该在这里找到一些好的信息。一个快速的谷歌搜索带来了以下内容。
https://stackoverflow.com/search?q=iOS+UDID+replacement
https://stackoverflow.com/search?q=iOS+UDID+replacement
Persistent UDID equivalent for iOS 7?
UIDevice uniqueIdentifier Deprecated - What To Do Now?
UIDevice uniqueIdentifier 已弃用 - 现在该怎么办?
general advice is to use CFUUID
to create your own UUID
, then persist it in the keychain
一般建议是使用CFUUID
创建自己的UUID
,然后将其持久化keychain