我想生成一个设备特定的随机uuid,即使用户卸载我的所有应用程序并重新安装不同于identifierforvendor也不会改变。我怎样才能实现这一点是Swift
答案 0 :(得分:1)
您可以使用以下函数创建UUID:
func getUniqueDeviceIdentifierAsString() -> String {
var appName: String? = (Bundle.main.infoDictionary?[(kCFBundleNameKey as? String)] as? String)
var strApplicationUUID: String = SSKeychain.password(forService: appName, account: "incoding")
if strApplicationUUID == nil {
strApplicationUUID = UIDevice.current.identifierForVendor.uuidString
SSKeychain.setPassword(strApplicationUUID, forService: appName, account: "incoding")
}
return strApplicationUUID
}
参考:How to preserve identifierForVendor in ios after uninstalling ios app on device?
答案 1 :(得分:0)
您需要创建随机UUID并将其保存到钥匙串。请尝试以下链接