iOS 7 webview和localStorage持久性 - 更新 [英] iOS 7 webview and localStorage persistence - update

查看:574
本文介绍了iOS 7 webview和localStorage持久性 - 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这里和其他地方都有人提出这个问题,但大多数答案都很旧,适用于旧版的iOS。

I know this question has been asked both here and elsewhere, but most answers are pretty old, applying to older versions of iOS.

应用程序(仅适用于iOS和Android)使用PhoneGap / Cordova和AngularJS,并希望使用HTML5 localStorage存储内容以供离线访问。

I'm developing a hybrid app (for iOS and Android only) using PhoneGap/Cordova and AngularJS and want to use HTML5 localStorage to store content for offline access.

http://caniuse.com/#search=localStorage 说 - 在iOS 5& 6 localStorage数据存储在以下位置:有时可能会被操作系统清除。

http://caniuse.com/#search=localStorage says - "In iOS 5 & 6 localStorage data is stored in a location that may occasionally be cleared out by the OS."

iOS 7 * webview的情况是什么,在什么情况下localStorage会保留或清除,操作系统或用户?

What is the situation with an iOS 7* webview, in what cases will localStorage persist, or get cleared out, either by the OS, or by the user?

应用程序的更新是否清除localStorage?

Will an update to the app clear localStorage?

用户在Safari上清除浏览器历史记录会同样适用于网络视图?

What about the user clearing browser history on Safari - will that apply to the webview too?

需要担心(或者我甚至可以控制)在fils系统上创建localStorage的位置。

Do I need to worry (or can I even control) where on the fils system the localStorage is created. I understand it should not be backed up on iCloud.

***** [考虑到91%的用户使用的是iOS7( https://developer.apple.com/support/appstore/ 截至2014年9月2日)我真的只是关注7,但欢迎输入约6太]

***** [Considering 91% of users are on iOS7 (https://developer.apple.com/support/appstore/ as of 2nd Sept '14) I'm really just concerned with 7, but welcome input about 6 too]

9月9日更新

经进一步调查,刚刚看到Nicole Bieber的评论,我仍然不能100%相信它的坚持性。我终于有了一个设备(iPad)和使用iExplorer我看到localStorage文件是在〜/ Library / Caches在应用程序沙箱中,见下图。

Upon further investigation, and just seeing the comment by Nicole Bieber, I'm still not 100% convinced about how persistent it is. I finally got a device (iPad) and using iExplorer I see that localStorage file is in ~/Library/Caches within the app sandbox, see image below.

从文档:

https://developer.apple.com/icloud/documentation/data-storage/index.html
可以再次下载或重新生成的数据应存储在/ Library / Caches目录。您应该放入Caches目录的文件示例包括数据库缓存文件和可下载内容,例如杂志,报纸和地图应用程序使用的内容。

https://developer.apple.com/icloud/documentation/data-storage/index.html Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

我只是这样做来设置数据:

I am simply doing this to set data:

  localStorage.setItem('foo','this is the FOO value');
  localStorage.setItem('bar','and this is the BAR value');

我缺少一些东西,我应该存储数据的方式,

Am I missing something either in the way I should store the data, or not seeing some "magic" that Cordova does?

>

推荐答案

如果你使用cordova,那个问题很久以前就解决了,即使是iOS 5和iOS 6。如果您使用的是最新版本的cordova,请担心。

If you are using cordova, that problem was fixed long time ago, even for iOS 5 and iOS 6. You shouldn't worry if you are using the latest version of cordova.

这篇关于iOS 7 webview和localStorage持久性 - 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆