Phonegap iOS 5.1 and localStorage

后端 未结 2 1245
旧时难觅i
旧时难觅i 2020-11-30 03:39

I was using localstorage for save one value in my App, that works with PhoneGap, but when Apple has released the new iOS 5.1, my App now doesn\'t save the value.

Doe

相关标签:
2条回答
  • 2020-11-30 03:59

    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.

    0 讨论(0)
  • 2020-11-30 04:14

    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

    0 讨论(0)
提交回复
热议问题