Hi there,
We are noticing a problem with user defaults. We have our data protection policy set NSFileProtectionComplete. When our app is launched in the background because of region monitoring when the phone is locked, user defaults is empty (only contains default system key-value pairs). That makes sense to us because of the policy above. We don't need to read user defaults at this time. The problem lies in the fact that even after we unlock the phone and open the app from the backgrounded state and into the active state, user defaults is still empty. I'm assuming this is because the defaults have been read into memory once and there doesn't seem to be away to force a purge and re-read from disk with our new authorization. Is there any way around this? With this unfortunate behavior, we have 3 solutions in mind:
1) Force crash the app in the background and have it restart when the user opens it from the home screen.
2) Save a backup of user defaults and read that file in when user defaults is empty or just completely get rid of user defaults and write everything to a file / use CoreData.
3) Change our data protection policy to CompleteAfterFirstUserAuthentication.
None of these are ideal changes though. Thanks for your time!
We are noticing a problem with user defaults. We have our data protection policy set NSFileProtectionComplete. When our app is launched in the background because of region monitoring when the phone is locked, user defaults is empty (only contains default system key-value pairs). That makes sense to us because of the policy above. We don't need to read user defaults at this time. The problem lies in the fact that even after we unlock the phone and open the app from the backgrounded state and into the active state, user defaults is still empty. I'm assuming this is because the defaults have been read into memory once and there doesn't seem to be away to force a purge and re-read from disk with our new authorization. Is there any way around this? With this unfortunate behavior, we have 3 solutions in mind:
1) Force crash the app in the background and have it restart when the user opens it from the home screen.
2) Save a backup of user defaults and read that file in when user defaults is empty or just completely get rid of user defaults and write everything to a file / use CoreData.
3) Change our data protection policy to CompleteAfterFirstUserAuthentication.
None of these are ideal changes though. Thanks for your time!