gpt4 book ai didi

ios - identifierForVendor.UUIDString 在不同的应用程序中生成相同的 Id

转载 作者:行者123 更新时间:2023-11-29 01:14:17 25 4
gpt4 key购买 nike

我有这段代码来获取 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。

我总是做的是复制并粘贴项目,更改 .plist 中的所有名称,更改 bundle 名称并创建新的配置文件,到目前为止,同一设备上的所有应用程序都有不同的 UUID。

我已在设备中安装了所有应用程序,并且所有应用程序都返回不同的 UUID,也许我忘记更改某些内容。

我需要更改 .plist 或构建配置中的其他内容吗?

我已经在.plist中更改了“ bundle 显示名称”、“ bundle 名称”、“URL标识符”和“URL方案”以及项目中的 bundle 名称,据我所知,我不需要更改任何内容否则。

提前致谢。

最佳答案

为了让您收到相同的供应商标识符,您应该是同一家供应商。

通常对于来自 App Store 的应用程序,如果由同一应用程序开发人员使用,它应该返回相同的 UUID,但是如文档中所写:

通常情况下,供应商是由 App Store 提供的数据确定的。如果应用程序不是从应用程序商店安装的(例如企业应用程序和仍在开发中的应用程序),则会根据应用程序的捆绑 ID 计算供应商标识符。假定包 ID 为反向 DNS 格式。

这意味着您还应该为您的应用提供相同的包 ID,例如

app1 : com.myId.app1

app2 : com.myId.app2

然后你会得到相同的identifierForVendor

查看此处的文档: identifierForVendor

关于ios - identifierForVendor.UUIDString 在不同的应用程序中生成相同的 Id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35411271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com