简体   繁体   English

应用程序在React Native中被杀死后用于存储数据的数据库

[英]Database for storing data after app is killed in React Native

I am making a React native app, with native services to scan for devices nearby. 我正在制作一个具有本机服务的React本机应用程序,以扫描附近的设备。 It works fine when the app is in foreground, but when the app is killed and the service detects a device, it wakes up the React Native part of app by headless JS and makes an API call using redux action, but it cannot store the data received from API call in reducer data. 当应用程序处于前台时,它可以正常工作,但是当应用程序被终止并且服务检测到设备时,它会通过无头JS唤醒应用程序的React Native部分,并使用redux操作进行API调用,但无法存储数据在减速器数据中从API调用接收到的。

I can't user AsyncStorage as the data is big and a JSON. 我无法使用AsyncStorage,因为数据很大且带有JSON。 How do I persist this data so that when the app is started, the users can see the data derived earlier from the API call? 如何保存这些数据,以便在启动应用程序时,用户可以看到先前从API调用派生的数据?

I would suggest you to use firebase for data storage as it is simple to integrate with React-native. 我建议您使用firebase进行数据存储,因为它很容易与React-native集成。 Here's the link to get started- 这是入门的链接-

https://firebase.google.com/ https://firebase.google.com/

Or Meteor Js is one of the other options you have. 或流星Js是您拥有的其他选择之一。

https://www.meteor.com/ https://www.meteor.com/

Edit:: 编辑::

If you want to use local storage then use the AsyncStorage. 如果要使用本地存储,请使用AsyncStorage。 Here's the link to the docs - 这是文档的链接-

https://docs.expo.io/versions/latest/react-native/asyncstorage/#__next https://docs.expo.io/versions/latest/react-native/asyncstorage/#__next

I just checked you can able to make offline apps with your database stored locally using SQLite. 我刚刚检查过,您可以使用SQLite在本地存储数据库的情况下制作离线应用程序。

npm install --save react-native-sqlite-storage

You can better check this article for more info: 您可以更好地查看本文以获得更多信息:

https://brucelefebvre.com/blog/2018/11/06/react-native-offline-first-db-with-sqlite/ https://brucelefebvre.com/blog/2018/11/06/react-native-offline-first-db-with-sqlite/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM