I have an iOS app where we can login and I'm using user defaults to store data like "firstLogin", "freshInstall", "userName", "sessionTime", etc. I am getting a problem where killing the app(double click on home and swipe up on the app to remove it) and relaunching it after a long time(after about 6hrs) is clearing all the userDefaults I'm setting and the app is opening in fresh install screen. It should actually open in logged in state.
I am using synchronize to properly save the userDefaults.
I don't have any code to explicitly delete the userDefault key-values or clear them. I have a few third party frameworks but I'm not sure how to check if those are causing this issue. How do I know where this problem is coming from? Is there any case where userDefaults gets cleared like that automatically?
The launch screen is determined based on the variable "isLaunchScreenShown" which is being saved in [NSUserDefaults standardUserDefaults]. After 1st install and launch screen is shown, the variable is set as true. When app is uninstalled, the UserDefaults are cleared. But in my case now, the UserDefaults' value for "isLaunchScreenShown" is returning null indicating that it is not set even though it is not the 1st launch after install.