Having App Restart Itself When It Detects Change to Privacy Settings

Having app restart itself when it detects change to privacy settings

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.

iOS App Restarts After Changing Revoked Privacy Settings

It is designed by iOS system and your app is forced to restart when you change the privacy settings. I think there is no way to get around it.

You can try to save the state in the method applicationDidEnterBackground and restore it when user come back again after changing the setting.

Refer:

Having app restart itself when it detects change to privacy settings

App crashes in background while changing permission

Activity restart every time when disable permission from setting

When you revoke permissions from app settings - Activity restarts and all it's components too. But in onCreate(...) savedInstanceState doesn't equal to null.

Thus you can use such hack:

if (savedInstanceState != null) {

}

Using the above hack app resume last fragmentC.

iOS 7 app crashes when changing calendar privacy

It's actually not a crash, although it appears that way when you are testing on your device through xCode. If you unplug your device and do some further testing, you'll notice that when you return to your app after changing the privacy setting, the app is killed as soon as the privacy setting has changed, and it relaunches when you return to it.

I'm not sure about simulator, but I'm guessing it's the same. (The app I'm developing uses Calendar, so I'm forced to do all of my testing on the device itself)

App killed by SIGKILL when changing privacy settings

I think it is a bug or at least poorly documented and unexpected behavior. But it does not crash it is just forced to restart. You will get a SIGKILL message but no Crash log.

If you are a registered apple developer you can check their forums for discussions about this issue

  • https://devforums.apple.com/message/715855
  • https://devforums.apple.com/message/714178

I don't know of any way how to prevent this behavior but feel free to file a bug report with apple. It is rumored they use bug duplicates as a way of measuring the bug severity.
Maybe you can store your app state in order to restore it when it restarts.

How can I prevent iOS apps from resetting after changing Camera permissions?

I'm sure that there is no other ways to prevent restarting app. Actually you will get a SIGKILL message but no Crash log when toggling settings. See below links-

  • https://devforums.apple.com/message/715855
  • https://devforums.apple.com/message/714178

The only way to prevent this scenario is to save the previous state of you application while terminating.

  • Store app your current data into a json/plist/NSUserDefaults/archive user model at applicationWillTerminate: method and
  • restore saved data at applicationWillEnterForeground:

For example- @SignUpViewController register for UIApplicationWillTerminateNotification which will fire when the app is about to terminate. Store user information there.

- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name: UIApplicationWillTerminateNotification object:nil];
}

- (void)applicationWillTerminate:(NSNotification *)notification
{
// store your data here
}

Hope this will help you:)

is it normal behaviour for an iOS app to go back to its home screen when users make a change to privacy settings?

This is fully normal behavior. iOS terminates the app (an app receives SIGKILL signal) in order the new privacy to be applied. You see an old view content, because it was captured with snapshotViewAfterScreenUpdates: when going background (see more at App life cycle docs).
Your responsibility here is to save the user data frequently enough. Read Apple's guide for more info.



Related Topics



Leave a reply



Submit