简体   繁体   中英

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. 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?

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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