use*_*169 1 apple-push-notifications udid ios
我的应用程序已连接到远程推送通知服务。在服务器端,他们希望为设备保留一个唯一的 ID,即使应用程序已删除并重新安装,它也不应该改变。我们可以获取设备 UDID 并发送到服务器吗?如果我这样做了,Apple 会从商店拒绝我的应用程序吗?而且我认为这是即使应用程序删除也能永久保留在服务器端的最佳 ID。
我需要你的建议。请帮我。谢谢
小智 6
正如它所提到的;安装应用程序时,其 uuid 是唯一的,但如果删除并再次安装应用程序,其 uuid 会发生变化。
所以克服了这个问题,我使用 Keychain Access 来检索和保存 uuid。
对于钥匙串访问包装器,我使用了名为的第三方
pod 'SwiftKeychainWrapper'
Run Code Online (Sandbox Code Playgroud)
为了获得 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
}
}
Run Code Online (Sandbox Code Playgroud)
这里会发生什么:如果在钥匙串访问中不存在 uuid,则使用 uuid 字符串保存它。每当您需要此 uuid 时,它将从钥匙串访问中获取。即使应用程序被删除/替换其唯一的。
| 归档时间: |
|
| 查看次数: |
2726 次 |
| 最近记录: |