本文介绍了当应用程式检测到隐私设置更改时,会重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序使用 ALAssets 框架访问用户的照片库。我写了一些代码来检测应用是否有权访问照片库,如果没有,我会显示一条警告消息,告诉用户在设置中打开应用的位置服务。

I have an app that uses the ALAssets framework to access to the users photo library. I wrote some code that detects whether or not the app has permission to access the photo library, and if it doesn't, I display an alert message which tells the user to turn on location services for the app in settings.

问题是,当用户手动更改隐私设置,然后他们重新打开应用程序时,iOS会强制该应用程序与SIGKILL崩溃。

Problem is, when the user manually changes the privacy settings and then they reopen the app, iOS forces the app to crash with SIGKILL.

我注意到另一个应用程序处理此问题的方式是通过某种方式检测隐私设置中的更改,并强制应用程序在下次用户打开时重新启动。有谁知道如何完成这个?

I've noticed that the way another app handles this is by somehow detecting a change in the privacy settings, and forcing the app to restart the next time the user opens it. Does anyone know how to accomplish this?

推荐答案

您误解了发生了什么。

You misunderstand what is happening. Your app is not crashing (though it may appear so if you are running the app with the debugger).

当您切换到设置应用(并且您的应用已暂停)时,您的应用不会崩溃(但如果您使用调试器运行应用,在后台)并更改隐私设置,被暂停的应用程序将被终止。当您切换回您的应用程式时,只需重新开始。这与您的应用因任何其他原因而被杀死没有什么不同。

When you switch to the Settings app (and your app is suspended in the background) and change the privacy settings, suspended apps are terminated. When you switch back to your app, it is simply started again. This is no different than your app being killed for any other reason.

由您自己编写应用程序来处理此问题,方法是恢复其以前的状态。你谈到的另一个应用程序只是将用户返回到之前的状态。许多应用程序都这样做。它与由于隐私改变而被杀害无关。该应用程序会在任何原因被杀死时恢复状态。

It is up to you to code your app to handle this by restoring its previous state. The other app you talk about is simply returning the user to the previous state. Many apps do this. It has nothing to do with being killed due to privacy changes. The app would restore state when being killed for any reason.

这篇关于当应用程式检测到隐私设置更改时,会重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:23