1

If this differs between versions of iOS or different types of state preservation, please say so.

In this case, I'm using application:shouldSaveApplicationState: and application:shouldRestoreApplicationState: – I'm not sure if state preservation/restoration is the correct term. (We're changing to application:shouldSaveSecureApplicationState: etc, but haven't released it yet.)

I'm asking because I'm looking into an error report that suggests that maybe a user got a bad state restored even after reinstalling the app, but I can't reproduce it, and I wasn't able to find docs that clearly stated what to expect if reinstalling.

Henrik N
  • 15,786
  • 5
  • 82
  • 131
  • Can't you test it yourself? – JoelFan Nov 07 '20 at 01:33
  • Hi @JoelFan. Like I say in the question, I have tested it myself and it did not restore, but a user report suggests it might not have worked the same way for them, and I would like to be more certain by e.g. finding docs that explicitly state what to expect. – Henrik N Nov 07 '20 at 08:55
  • 1
    Here's an idea.... use https://stackoverflow.com/questions/26830285/how-to-detect-apps-first-launch-in-ios to tell if your app is being launched for the first time. If so, clear whatever state you are worried about being left over from the last time the app was installed. The method in the linked question is guaranteed to do what you need, even if the app was previously installed and deleted. – JoelFan Nov 08 '20 at 17:47

2 Answers2

1

It wouldn't be be logical for it to persist after app uninstall, so no, it does not.

Please note application:shouldSaveApplicationState: and application:shouldRestoreApplicationState: are deprecated since iOS 13.2.

EDIT: By uninstall I mean the user actively removed the app. I'm not talking about an app being off loaded by the iOS due to storage, at this case it is saved. The whole topic is extremely vague in the Apple documentation.

thedp
  • 8,350
  • 16
  • 53
  • 95
  • Thank you. I agree, but wasn’t able to find a source to state that explicitly, and I had an error report that seemed to suggest that it happened. Do you know of any doc that makes this explicit? Regarding the deprecation - thank you. Mentioned in the question that we’re changing it in the next update :) – Henrik N Nov 06 '20 at 23:24
  • I can't find an official reference to the behavior, but this is nothing new with Apple. And your question is the top search result on Google... But I did find this: https://developer.apple.com/documentation/uikit/uiviewcontroller/restoring_your_app_s_state and it states additional info, but I'm not sure if it's this way only during debug. – thedp Nov 08 '20 at 15:15
  • Thanks again, @thedp. Any bit of additional info in particular you were thinking of? I found my way to https://developer.apple.com/documentation/uikit/view_controllers/preserving_your_app_s_ui_across_launches saying "UIKit can discard state preservation data at its discretion, allowing your app to return to its default state." That doesn't answer my question, but could theoretically explain why I can't reproduce the issue, if it only discards it when *I* reinstall for some reason, but not the error reporter. But I'm not sure how far to trust this error report. Hence my asking here :) – Henrik N Nov 08 '20 at 21:07
  • @HenrikN I'm curios. How do you even know the user (maybe) got a bad state restore? – thedp Nov 09 '20 at 08:59
  • The user claimed that after reinstalling the app, they saw the wrong content on a certain tab – which could be explained by having navigated there and then that state being restored. But again, not sure how far to trust it – this is just one line of inquiry to see how likely it seems. – Henrik N Nov 09 '20 at 12:27
  • @HenrikN "Reinstall" might be a misleading description... Does this mean the user removed the app, and then installed it again? Or maybe an app update is the same thing as reinstall for that user? Or maybe installation after an off loaded app. Without more information you're guessing. Also, please look at the EDIT in my answer – thedp Nov 10 '20 at 11:58
  • I had the same thought, so I specifically asked if they uninstalled by holding down on the icon, pressing the "x" etc, so I have confirmed their idea of "reinstall" is the same as mine. Noted about the EDIT. I agree it's not clear in the docs I could find – that's why I asked here :) – Henrik N Nov 10 '20 at 16:34
0

The answer is no, it does not.

JoelFan
  • 37,465
  • 35
  • 132
  • 205