简体   繁体   English

从AppStore升级应用程序时,有没有一种方法可以删除所有数据/缓存

[英]Is there a way to remove all the data/caches when upgrading app from AppStore

Small percentage of my user get ugly bug related to WKWebView when updating to the latest version of my app from AppStore. 从AppStore更新到我的应用程序的最新版本时,一小部分用户会收到与WKWebView相关的丑陋错误。 The bug goes away when the app is removed and installed all over again. 重新删除并重新安装该应用程序后,该错误消失。 Is there a way to remove old data/caches during the upgrade? 有没有办法在升级过程中删除旧数据/缓存?

All the code is removed when you update an app. 更新应用程序时,所有代码都将被删除。 If your app changes how it uses for example data that isn't removed, such as NSUserDefaults you have to add logic in your code to handle "old" data being present. 如果您的应用更改了使用方式,例如未删除的数据(例如NSUserDefaults),则必须在代码中添加逻辑以处理存在的“旧”数据。

Not sure if this will work but here is two possible approaches: 不知道这是否行得通,但这是两种可能的方法:

1. 1。

When your app loads up, in AppDelegate check for saved data inside the didLaunchWithOptions() : 当您的应用加载时,在AppDelegate中检查didLaunchWithOptions()保存的数据:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    if let data = userDefaults.valueForKey("<yourKey>") {
        userDefaults.removeObjectForKey("<yourKey>")
    }

    return true
}

You'll have to insert the keys used in your application for saving stuff instead of <yourKey> , of course. 当然,您必须插入应用程序中用于保存内容的键,而不是<yourKey>

2. 2。

You could also try the following code, that will erase all the contents of NSUserDefaults, which will make the key unnecessary: 您还可以尝试以下代码,该代码将擦除NSUserDefaults的所有内容,这将使密钥变得不必要:

NSUserDefaults.standardUserDefaults().removePersistentDomainForName(NSBundle.ma‌​inBundle().bundleIdentifier!)

Hope that helps :) 希望有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Appstore删除应用程序并上传具有相同名称的新应用程序 - Remove app from Appstore and Upload new app with same name iOS应用程序,通过AppStore更新应用程序时,是否可以订阅事件? - iOS app, is there a way to subscribe to an event when an app is updated through AppStore? 如果从应用商店销售中删除,也从设备中删除 ios 应用程序 - Remove ios App From Device also if removed from appstore sales 有没有一种方法可以通过密码保护从Appstore下载Mac App? - Is there a way to password protect the download of mac app from appstore? 有没有办法从 MacBook Pro 2011 向 AppStore 提交应用程序? - Is there a way to submit an app to AppStore from MacBook Pro 2011? 从 Instagram 打开时,始终调整深层链接重定向到 Appstore - Adjust deeplink redirects to Appstore all the time when opened from Instagram 正确的方法来删除(清除)iOS应用程序的所有钥匙串数据 - Correct way to remove(purge) all keychain data for an iOS app 从appstore更新后运行iOS应用程序会发生什么? - What happens to running iOS app when it gets updated from appstore? 从AppStore或TestFlight启动时,应用崩溃 - App crashing when launching from AppStore or TestFlight but working fine elseways 没有AppStore,有没有办法更新iOS应用? - is there way to update iOS app without AppStore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM