删除并重新安装应用后,iOS钥匙串数据将仍然存在吗? [英] iOS Keychain Data will persist after app deleted and reinstall?

查看:107
本文介绍了删除并重新安装应用后,iOS钥匙串数据将仍然存在吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,Apple禁止在iOS设备中获取唯一ID.但是有时我们需要确定设备,例如,当该应用程序首次与唯一的一个用户一起安装时就获得了奖励.我们不想在一台设备上签署(赚取奖金)多个用户.

As you know, getting a unique ID in iOS devices is banned by Apple. But sometimes we need to identify devices, for example, got bonus when the app first installed with the only once user. We don't want to sign(earn the bonus) multiple users in one device.

因此,我们从设备获取了vendorID,并将此数据保存在钥匙串上(vendorID随时间变化,但我们不想更改ID).之后,我们检查此数据在钥匙串上是否可用.我阅读了此线程卸载后iOS自动删除钥匙串项,相关的钥匙串数据将在删除后该应用程序已删除.

So, we got vendorID from the device and save this data on a keychain(vendorID changed the time by time, but we don't want to changingID). After that, we check this data is available on a keychain. I read this thread iOS autodelete Keychain items after uninstall that related keychain data will be removed after the app deleted.

但是当我尝试这种情况时.我的钥匙串数据不会删除,并且删除后仍会保留钥匙串数据.

But when I try this scenario. My keychain data don't delete and keychain data persistent after deleting.

因此,我的问题从这一点开始提出.有人知道这个问题吗?我的应用删除后,钥匙串数据将保留或删除所有钥匙串数据.

So my question is raized from this point. Anyone know about this issue? After my app deleted, keychain data will be persisted or removed all keychain data.

卸载后会删除钥匙串数据吗?

查看我的钥匙串数据保存功能.

To look at my keychain data saving function.

class func getUniqueDeviceID() -> String {
    guard let uniqueDeviceId = KeychainKeeper.shared.uniqueDeviceID else {
        let deviceId = (UIDevice.current.identifierForVendor?.uuidString)~
        KeychainKeeper.shared.uniqueDeviceID = deviceId
        return deviceId
    }
    return uniqueDeviceId
}

请不要提供其他解决方案.我们陷于这种情况.我们要确保删除的应用程序钥匙串之后是否将被删除

Please do not offer other solutions. We are stuck in this scenario. We want to sure after the deleting app keychain will be deleting or not

推荐答案

钥匙串数据现在始终存在.

Keychain data always persist now.

自动删除钥匙串值的beta是10.3,但是由于某种原因,他们消除了这种可能性.我想许多应用程序习惯了不可丢下钥匙串.

The auto-delete of keychain value was in a beta of 10.3, but for some reason, they removed this possibility. I guess to many applications get used to not droppable keychain.

检查此问题.

有一个超简单的方法 UserDefaults :

func clearKeychainIfWillUnistall() {
let freshInstall = !UserDefaults.standard.bool(forKey: "alreadyInstalled")
 if freshInstall {
    KeychainKeeper.shared.clear()
    UserDefaults.standard.set(true, forKey: "alreadyInstalled")
  }
}

AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  self.clearKeychainIfWillUnistall()
}

我知道的最简单的解决方法.希望对您有所帮助.

The simplest workaround that I know. I hope it will help.

这篇关于删除并重新安装应用后,iOS钥匙串数据将仍然存在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆