Phonegap iOS 5.1 and localStorage

Solution 1:

There was a large thread in the phonegap group that talked about this problem. Basically its because they now treat localStorage as a temp item which can be deleted at any point. Never fear there are very smart people at work!

here's the thread - https://groups.google.com/forum/?fromgroups#!topic/phonegap/RJC2qA9sDnw

here's the code - http://pastebin.com/5881768B

Solution 2:

In iOS 5, localstorage was made persistent by default, by Apple. In iOS 5.1, localstorage was made a temporary folder that could be deleted by the OS any time storage was constrained. In iOS 6, localstorage was made an optionally persistent folder with a flag in the setting.

Phonegap 2.0 targeted iOS 5.1 and provided a plugin mechanism to provide persistence even though iOS did not.

With iOS 6 and phonegap 2.1 attempt was made to use the plugin only if the iOS version is 5.1 and fall back to the iOS native mechanism for persisting the folder.

However there is a bug with this fix, on iOS 6, where the localstorage folder gets deleted the first time, the data is stored: https://issues.apache.org/jira/browse/CB-1535 The bug report also has the patch; however it is not yet scheduled to be a part of any of the PhoneGap release version; so you would have to manually apply the patch.