I have a app built with cordova ios 3.8.0.
When I updated the app to new version which is built with 4.1.1 LocalStorage returns empty. I cannot retrieve the data saved by previous version.
Works in iOS 8 and 9
Does not work in iOS 10.2
Has anyone experienced this issue? Any ideas?
Please help.
Cordova-ios: current 4.1.1, previous 3.8.0
Cordova CLI: current 6.1.1
xcode: current 7.2.1
Problem is the app is already in app store and it uses localStorage.
The new version uses both LocalStorage and ios KeyChain. But we need to get saved user information (LocalStorage) from previous version.
I’ll update Cordova and check.
But my question is why it works in 8,9,10 and not in 10.2.
Tested with latest cordova version but issue exists
cordova cli: 6.5.0
cordova-ios: 4.3.1
This issue is reproducible in simulator as well.
I manually copied localstorage files from old location to new location and I was able get old local storage data
Old files
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/63263C1A-4093-47EB-8F02-9ECB2E6E379A/Library/WebKit/LocalStorage/file__0.localstorage
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/63263C1A-4093-47EB-8F02-9ECB2E6E379A/Library/WebKit/LocalStorage/file__0.localstorage-wal
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/63263C1A-4093-47EB-8F02-9ECB2E6E379A/Library/WebKit/LocalStorage/file__0.localstorage-shm
Copied to this location
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/A5499C1C-FB6D-4B28-9927-E7A13FFE9913/Library/Caches/file__0.localstorage
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/A5499C1C-FB6D-4B28-9927-E7A13FFE9913/Library/Caches/file__0.localstorage-wal
Devices/9D3BC7A7-A6AD-4765-9324-A0A72C600CA5/data/Containers/Data/Application/A5499C1C-FB6D-4B28-9927-E7A13FFE9913/Library/Caches/file__0.localstorage-shm
I think Cordova does not copy old localstorage to new location after app is updated.
No idea why it behaves differently in iOS 10.2 only.
Can anyone please point me to the code where old local storage files are copied (in CDVLocalStorage)?
I really need to get this fixed.
I am not sure if Cordova “copies” localStorage after an update - as I understood it this is pure iOS doing its thing. And localStorage sometimes gets lost.
If the upgrade of cordova-ios from one to another version is the cause then maye first do an update with the old cordova-ios version that saves the data a different way. When this is rolled out and enough users have it, do another update that goes to the new cordova-ios version. Won’t work for all users, but some.
In our case, we came up with an alternative. All the user data is saved in our databases as well. So we wrote an new service endpoint mobile app can call and get data. Mobile app will call the endpoint if local storage is empty, and save data in Local Storage again.
Ideally Local Storage should be copied in case of an app update.
This issue occurred to me in Android too. In Android the update was crosswalk -> non crosswalk.