We've seen an issue whereby when our app is backgrounded, quit and later launched again it appears that the system has deleted all files from the app container, cleared User Defaults and cleared the app's Keychain items.
No action was taken by the user to trigger this.
No code within the app clears all 3 of these things (certain items in the Keychain we never clear and these are gone too) and there's no logs or tracking events to suggest the app has done this itself.
This suggest to me that, for some reason, the system itself is deleting, or making inaccessible, all of the app's data and even its Keychain items (something that I thought iOS never did itself?).
For the user affected (on iOS 14.6) this happened repeatedly 4 times over the span of 2 days and then suddenly stopped with no clear reason. It's also sporadically happened every few months for them. We unfortunately haven't been able to capture a sysdiagnose thus far.
I'm keen to hear what might trigger this kind of behaviour by iOS or if I'm missing something?