本文介绍了localStorage在使用Cordova 1.7和iOS 5.1.1重新启动应用程序时清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我广泛的阅读,iOS 5.1 localStorage / WebSQL行为更改,苹果已经完全推广到Cordova 1.6.0。
然而,当我在Cordova 1.7.0和iOS 5.1.1的我的(新)应用程序上运行时,我仍然看到丑陋,不正确的行为。



使用window.localStorage存储和检索数据。例如。
window.localStorage.getItem(activeFormId)
window.localStorage.setItem(activeFormId,formId);
这些工作在基于Cordova的应用程序的同一会话期间完美无缺。如果我使用主要的iOS按钮背景的应用程序,然后恢复,这通常也很好。



然而,一旦我杀了应用程序(双击,长按,点击红色圆圈)并重新启动,所有localStorage数据都丢失。我已经验证了这个与jsconsole.com以及。



我需要采取额外的步骤,以确保持久性错误修复工作?非常感谢任何帮助。

解决方案

尝试使用1.7 - 我有一个类似的问题,一旦我升级到1.7一切都像



尝试使用localStorage与window.localStorage语法。

还要设置您尝试的内容作为全局变量调用...

  var globalVar; 

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


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.

解决方案

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');
}

这篇关于localStorage在使用Cordova 1.7和iOS 5.1.1重新启动应用程序时清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:42