访问我的应用程序本机版本的cordova/phonegap中window.localStorage中存储的数据? [英] Access data stored in window.localStorage in cordova/phonegap in my react native version of the app?

查看:167
本文介绍了访问我的应用程序本机版本的cordova/phonegap中window.localStorage中存储的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新(完全重写)我在cordova/phonegap中编写的应用程序,以响应本机.在cordova中,我使用window.localStorage存储持久数据,但是现在我切换本机响应,我不希望我的所有用户在批准此版本并更新时都释放其数据.用户更新后,是否有任何方法可以从我的cordova应用程序获取持久数据并以应用程序本机版本访问它们?

I'm updating (completely re-writing) my app that I wrote in cordova/phonegap to react native. In cordova I used window.localStorage to store persistent data but now that I'm switching react native I don't want all my users to loose their data when this version is approved and they update. Is there any way to get the persistent data from my cordova app and access it in react native version on the app after the user updates?

我写了一个react native模块来解决这个问题.这是链接:

I wrote a react native module to solve this problem. Here's a link:

https://github.com/wootwoot1234/react-native-webkit-本地存储读取器

推荐答案

尝试查看在这里回答的这个问题

Try looking at this question that was answered here How do I access HTML5 local storage created by PhoneGap on iOS?. Make sure you read the comments because it seems as if apple may have moved it in the newer versions.

如果这不能以另一种方式起作用,那么我可以想到只是在您的应用程序中加载一个Webview(假设它仍然具有所有相同的数据).然后,您可以从应用程序中的该Web视图访问本地存储.

If that doesn't work another way I can think of doing it is just loading up a webview in your app (assuming it still has all of the same data in there). Then you could access the local storage from that webview in the application.

一旦您能够读取本地存储,我建议将其移至更好的存储选项.我知道有一个用于响应本机的sql lite适配器,因此可能对您有用.因此,如果您希望创建一个本地绑定,请在这里 https://facebook.github.io/react-native/docs/native-modules-ios.html#content .然后,您将能够将该本地存储反馈回您的应用程序.

Once you are able to read the local storage I would recommend moving it to a better storage option. I know that there is an sql lite adapter made for react native so that might work for you. So if you wanted you could create a native binding found here https://facebook.github.io/react-native/docs/native-modules-ios.html#content. Then you would be able to feed that local storage back into your application.

这篇关于访问我的应用程序本机版本的cordova/phonegap中window.localStorage中存储的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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