localStorage cleared on app restart with Cordova 1.7 and iOS 5.1.1

余生长醉 提交于 2020-01-10 04:40:31

问题


From my extensive reading, the iOS 5.1 localStorage/WebSQL behavior change that Apple instituted has been fully rolled into Cordova 1.6.0. However, while running on my (new) application on Cordova 1.7.0 and iOS 5.1.1, I am still seeing ugly, incorrect behavior.

I use window.localStorage to store and retrieve data. E.g. window.localStorage.getItem("activeFormId") window.localStorage.setItem("activeFormId", formId); These work flawlessly during the same session of the Cordova-based app. If I background the app with the main iOS button then resume, that usually works as well.

However, the moment I kill the application (double-tap, long-press, tap the red circle) and relaunch, all localStorage data is lost. I have verified this with jsconsole.com as well.

Are there additional steps I need to take to ensure the persistence bug fixes are working? Any help is greatly appreciated.


回答1:


Try using 1.7 - I had a similar issue and once I upgraded to 1.7 everything worked like it used to.

Try using localStorage vs window.localStorage syntax.

Also set what ever you're trying to call as a global variable...

var globalVar;

function onDeviceReady(){
  globalVar = localStorage.getItem('something');
}


来源:https://stackoverflow.com/questions/10881059/localstorage-cleared-on-app-restart-with-cordova-1-7-and-ios-5-1-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!