gpt4 book ai didi

ios - 如何在iOS中删除并重新安装应用程序来唯一标识设备?

转载 作者:行者123 更新时间:2023-11-28 19:44:43 27 4
gpt4 key购买 nike

我的应用程序已连接到远程推送通知服务。在服务器端,他们希望为设备保留一个唯一的 ID,即使应用程序已删除并重新安装,它也不应更改。我们可以获取设备 UDID 并发送到服务器吗?如果我这样做了,Apple 会拒绝我的应用程序吗?而且我认为即使应用程序已删除,这是永久保留在服务器端的最佳 ID。?

我需要你的建议。请帮我。谢谢

最佳答案

如其所述;安装应用程序时,它的 uuid 是唯一的,但如果应用程序被删除并再次安装,它的 uuid 会改变。

为了克服这个问题,我使用钥匙串(keychain)访问来检索和保存 uuid。

对于钥匙串(keychain)访问包装器,我使用了名为

的第三方
pod 'SwiftKeychainWrapper'

为了获取 uuid,我创建了这个方法。

func getUDIDofDevice() -> String {
//Check is uuid present in keychain or not
if let deviceId: String = KeychainWrapper.standard.string(forKey: "deviceId") {
return deviceId
}else{
// if uuid is not present then get it and store it into keychain
let key : String = (UIDevice.current.identifierForVendor?.uuidString)!
let saveSuccessful: Bool = KeychainWrapper.standard.set(key, forKey: "deviceId")
print("Save was successful: \(saveSuccessful)")
return key
}
}

这里会发生什么:如果在钥匙串(keychain)访问中不存在 uuid,则使用 uuid 字符串保存它。每当您需要此 uuid 时,它将从钥匙串(keychain)访问中获取。即使应用程序被删除/替换它的唯一性。

关于ios - 如何在iOS中删除并重新安装应用程序来唯一标识设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32775871/

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