我有这个代码来获取UUID:
//Initialaze the keychain helper
KeyChainWarp * keychain =[[KeyChainWarp alloc] initWithService:@"KeyChainService" withGroup:nil];
//Get the data from the keychain.
NSData * data =[keychain find:@"UUIDString"];
if(data != nil)
{
//Set the global variable.
userId = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
else
{
//Get the UUIDString for the first time.
NSData *value = [[UIDevice currentDevice].identifierForVendor.UUIDString dataUsingEncoding:NSUTF8StringEncoding];
//Insert in the keychain.
if([keychain insert:@"UUIDString" :value])
{
//Set the global variable.
userId = [[NSString alloc] initWithData:[keychain find:@"UUIDString"] encoding:NSUTF8StringEncoding];
}
}
即使用户删除了应用程序,我们的想法是保持持久性,直到现在我从不同的应用程序中的函数接收到不同的UUID,但现在我有一个应用程序从另一个应用程序返回相同的UUID。 / p>
我一直在做的是复制和粘贴项目,更改.plist中的所有名称,更改包名称并创建新的配置文件,直到现在,来自同一设备的所有应用程序都具有不同的UUID。
我已经在我的设备中安装了所有应用程序,并且所有应用程序都返回了不同的UUID,也许我忘了更改某些内容。
我是否需要更改.plist或构建配置中的其他内容?。
我更改了.plist“Bundle display name”,“Bundle name”,“URL identifier”和“URL Schemes”以及项目中的包名称,据我所知,我不需要更改任何内容其他
提前致谢。
答案 0 :(得分:1)
为了让您收到供应商的相同标识符,您应该是同一个供应商。
通常对于来自App Store的应用程序,如果由同一个应用程序开发人员使用,它应返回相同的UUID,但是如文档中所述:
Normally, the vendor is determined by data provided by the App Store. If the app was not installed from the app store (such as enterprise apps and apps still in development), then a vendor identifier is calculated based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format.
表示您还应为应用提供相同的包ID,例如
app1 : com.myId.app1
app2 : com.myId.app2
然后你会得到相同的identifierForVendor
。
请查看此处的文档: identifierForVendor
答案 1 :(得分:0)
正如Blue Gene在接受的回答中所说的那样,它应该返回与所有具有相同包ID格式的应用程序相同的UUID,但在我的情况下,这不是我几天前得到的结果,所以直到现在我在我的所有应用程序中都有一种奇怪的行为,我将在这里发布我的发现以帮助将来的某个人。
注意这不是正确的答案,所谓的正确行为是Apple Docs中描述的行为。
这是我的包ID在几天前工作的示例:
Bundle Id示例
com.company.clientnamewith4letters = new unique id
com.company.clientnamewith6letters = new unique id
com.company.sameclientnamewith4lettersaddingLightattheend = new unique id
com.company.sameclientnamewith6lettersaddingLightattheend = new unique id
但是几天前:
com.company.newclientnamewith6letters = new unique id
com.company.newdifferentclientnamewith6letters =相同的新唯一ID
com.company.newdifferentclientnamewith8letters =相同的新唯一ID
等等......
我所有的旧应用程序都返回了不同的UUID,但是我的所有新应用程序都返回了Apple认为应该是的UUID,这种行为在我的前4个应用程序中出错并在我的新6个应用程序中更正。
Apple说,如果我的所有应用程序都以com.company开头,我应该得到相同的UUID,但不是我的情况,我必须补充一点,我在第一个应用程序和我的上一个应用程序之间有两年多的时间,我的猜测是有一个错误,现在工作正常。
我认为唯一的区别是我生成配置文件的时间,我的猜测是添加了一些新内容以保证UUID是相同的。
当我在KeyChain中保存UUID时,我已经在我的所有应用程序中进行了测试,如果现在我正在获取新的UUID而事实并非如此,那些旧的UUID会产生相同的旧的和不同的UUID。
我希望将来可以帮助某人。
关心和快乐的编码。