Database for storing data after app is killed in React Native

允我心安 提交于 2021-02-08 10:10:27

问题


I am making a React native app, with native services to scan for devices nearby. 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.

I can't user AsyncStorage as the data is big and a 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?


回答1:


I would suggest you to use firebase for data storage as it is simple to integrate with React-native. Here's the link to get started-

https://firebase.google.com/

Or Meteor Js is one of the other options you have.

https://www.meteor.com/

Edit::

If you want to use local storage then use the AsyncStorage. Here's the link to the docs -

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




回答2:


I just checked you can able to make offline apps with your database stored locally using 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://stackoverflow.com/questions/54569936/database-for-storing-data-after-app-is-killed-in-react-native

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