检测即将删除的iOS应用程序? [英] Detect iOS application about to delete?

查看:78
本文介绍了检测即将删除的iOS应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的 iOS 应用程序,当用户a即将删除应用程序时会触发什么事件?

解决方案

没有这样的事,抱歉。



你能做的最好做的是检查 UIApplicationWillTerminateNotification 通知,但更重要的是保存应用程序的状态(例如在服务器上),当它转换到后台并交叉用户的时候不会在未运行时删除您的应用。因为一旦你的应用程序关闭,你就不再拥有任何控制权。



编辑:因为你想在删除应用程序时清除钥匙串的内容,我建议你带看看这个其他问题。基本上,一些答案建议不要在删除时删除钥匙串的内容,而是在用户首次使用NSUserDefaults启动应用程序时。



编辑:Luis Ascorbe评论了一个想法:使用Push Notification的反馈服务( https://stackoverflow.com/a/7912045/157401)当然,这远非完美(并非所有用户都订阅通知,通知令牌可能因其他原因而无效等),但这仍然需要考虑。



<编辑:从iOS 10.3 Beta 2开始,钥匙串数据似乎不再显示删除应用时会保留。


For my iOS application, what event will be triggered when user a is about to delete the application?

解决方案

No such thing, sorry.

The best you can do is do is check for the UIApplicationWillTerminateNotification notification but more importantly save the state of your app (on a server for example) when it's transitioning to the background and cross your fingers your user will not delete your app when it's not running. Because once your app closed, you don't have any control anymore.

EDIT: Since you want to clear the keychain's content when the app is deleted, I suggest you take a look at this other question. Basically, what is suggested by some answers there is not to remove the content of the keychain at delete time, but instead when the user first launches the app using NSUserDefaults.

EDIT: Luis Ascorbe commented with an idea: using Push Notification's feedback service ( https://stackoverflow.com/a/7912045/157401 ) Of course, that's far from perfect (not all users subscribe to the notifications, notification tokens might be invalidated for other reasons, etc.) but that's still something to consider.

EDIT: Starting with iOS 10.3 Beta 2, keychain data appears to no longer be persisted when an app is deleted.

这篇关于检测即将删除的iOS应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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