$localForage (localStorage/indexedDB) periodically cleared on iOS


I recently submitted my first ionic/cordova app on android and iOS and the more users I have, the more feedback I get regarding cleared app storage. For my app I need to store an user access token on the device (currently with $localforage and indexedDB) which is checked whenever the app is started.

Unfortunately when memory on iOS is low, iOS is clearing app storage (Localstorage - is it cleared after app restarts/ periodically in iOS?) and the access token is lost. Therefore my question is how to save such important data to prevent data loss and if you guys have also experienced this behavior?


In case someone else is also experiencing this behavior, I fixed it by using NSUserPreferences (https://github.com/apla/me.apla.cordova.app-preferences) and add a 500ms delay before loading values from storage. It appears that NSUserPreferences sometimes needs more time to initialize, therefore the delay.

1 Like

Did the fix permanently solve your problem? I am facing a similar issue and thinking of doing the same as you have pointed out.