Persist localstorage in cordova app when app updates via app store

I have a iOS app built using Ionic. Version 1 of my app (which has been released for a while) stores some data using HTML5 localStorage. I’m ready to release version 2 but updating the app (I’ve simulated both via xcode, itunes and via a testflight install) wipes all the data stored in localstorage.

It seems the localstorage db is stored in Library/Caches/ if that is helpful.

For info I’m using:

Cordova 3.9.2 and Ionic 1.1.1

After spending all day searching SO and various other sites I’m still no wiser.

Is there a way to prevent this? Interested to hear from anyone using localStorage on a released cordova app.

There’s another issue with localstorgae on iOS, it can be cleared sometimes when system needs disk space.

This is why I moved away from this solution to use KeyChain and generating my own UUID.

Yeah to solve that issue I’ve moved to PouchDB in version 2 with some code that grabs the old local storage data and adds it to the PouchDB (SQLlite). The issue being, the original localstorage gets wiped on update… So many conflicting posts on this though, found losts of SO posts suggesting Cordova fixed this and it should no longer be an issue.

Would love to hear from anyone who has done an iOS update and is using localstorage.

I found interesting combination with file system if you want to avoid SQL lite with LokiJs and filesystem adapter


http://lokijs.org/

Thanks - I looked at LokiJS but decided to go with Pouch as eventually I may sync with a couchDB.

Does anyone know of a way I can grab whats in localstorage and write it to a file that won’t be killed when the app updates, then I could grab that and populate Pouch.

I am writing my first App at the moment and I am using localForage. Will the localForage storage also be erased when updating an iOS app?

If localstorage is emptied on an AppStore update (I don’t know if this is the case - Can you provide any links about this?), then you have no way to deploy any code that will grab the data that is stored in localstorage. It will already be gone when whatever code you deployed is executed :confused:

I’m having a similar problem with localStorage but when I uninstall/reinstall the app and then I open the app from the AppStore/TestFlight app It skips some validations that rely on localStorage being empty is like if the context of the localStorage is being persistent when doing app-linking navigation on iOS9 (Opening the app from the appStore also adds a backButton on my app).

This is just a guess, is hard to debug this corner case because the app in the store cannot be debugged.

Can somebody confirm that an update (app/playstore) actually wipes the $localstorage ? I’ve found this SO post and also this SO post (see comments), both of them state that the $localstorage persists after an update. Any help would be much appreciated.

LocalForage uses fallbacks to find the “most persistent” technology available i think, shouldnt be an issue.

localForage uses localStorage in browsers with no IndexedDB or WebSQL support
GitHub - localForage/localForage: 💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.