Storing large data in react native for offline usage - react-native

For our app we need the app the work offline 100% with the most recent data.
Normally the app uses a symfony api platform API to fetch data paginated server side.
But when someone is using the app in a area without Internet he still need to be able to access all data to make a new job and que it for when he is online.
So our tough is to make a json that has all the data and send it to the phone when the phone has connection.
When the phone is using the app live, it will use pagination from server and fetch data.
And when offline it will use the local downloaded data file.
Problem is the data is large, so storing it is the problem.
We are now using redux persist and we see so many people have problems with crashes and mobile ram.
We also thought of using sqlite or just async to store a json file, or download a sqlite file from the app.
How do you guys feel about this

You can use react-native-local-mongodb. This can help you store a json database on your phone.
Other option is to have react-native-sqlite-storage in case your database has to be relational and requires table.
You will have to sync this local copy with the server once this user is online. This too can be done if you have the timestamp saved of the last sync. So after that, you ll just have to sync the data created after that timestamp.
However, I had also implemented react redux persist and it didnt crash. I suppose, the reason for crash must me something else.

Related

Should I use AsyncStorage for large amounts of data?

We are wanting to implement an offline mode for our react-native application. We will be working with quite large amount of data (aprox. 40-50mb). It is an array of aprox. 16000 objects.
As far as I know, there are two ways to save this data.
Using AsyncStorage - android has a limit of 6mb, but I've read somewhere, that it can be increased.
Using json file - Downloading that data as json file using react-native-background-downloader and then using react-native-fs to save it and load it if the user has no connection to internet.
Personally I think that the second option is better, even though it requires permission to file storage.
Am I missing any other factors to consider? Are there any other options for offline access?
In the end opted out for usage of the json file as there is limit on android. On load of the application I take these data and load them into variable in mobX store. Which functions same as any variable.
I was afraid that mobile phones will have problem sorting across the 16000 objects in array, but there have been no reports of this thing going wrong so far. (In production for 4-5 months right now)
So basically when you hit "enable offline mode" I ask for the file storage permission and download the file using react-native-fs.
Then on the next startup of the application I just read the data off the JSON file.

Confused about data flow and parts involved in sending iOS push notifications through a database

I'm creating a college dining menu app, in which I need to send push notifications based on the daily menus.
I only know objective-c, so I'm inexperienced with concepts such as databases that are needed for this task.
What I understand:
I need to parse the data from the online dining menu and store it in
some database
I check daily if the current menu has what I'm looking for, and alert the Apple Push Notification service if it does
Above two points must be done without independently of my app, since the app won't be open at all times.
Resources I found:
Heroku -- a cloud platform where I can store the data
Helios -- "provides backend services" like push notifications and can be implemented w/ Heroku (not entirely sure what it does)
Ruby on Rails
What I'm confused about:
How do I store the data in the database? Do I have to write a program
with ruby on rails that scrapes the web data and then somehow add
this to Heroku?
What exactly does Helios help me with?
What is my actual objective-c app code responsible for doing?
Are there any other parts/better resources I left out?
Any pointers would help. Also, I'm trying to avoid using any paid services for server/database tools.
Let me explain it for you:
Heroku is just a way to host on the Amazon AWS cloud infrastructure. It doesn't store your DB - it provides access to db
infrastructure, but doesn't host the DB itself
If you want to store cross-platform data in your iOS application, you need to connect to a third-party db (this is how FB works)
This means if you want to keep up with menu updates on your phone, you'll need to firstly have a central db (hosted on Heroku's
recommended db infrastructure), and then use the iOS app to connect to
it
The trick will be to take any updates from the database & display them using a push notification. I don't know about this, but the Rails part I can tell you about:
If you want to store a menu in a db, you'll need a db. You can get one either at AWS or Heroku (notice how the db != rails)
Next, you need data in that db. This is where rails comes in - you'll be best using an infrastructure such as Rails or CakePHP to manage the data
If you create a simple Rails app with admin backend, you'll be able to upload as much data as required to your db. If you need to "scrape" the data, you can create a simple script & cronjob to get it & put into the db
Finally, each time the db updates, you need to send the update to your iOS app. I don't have much experience with this, but it seems you need to use the pub/sub programming pattern to send the updates to your device (displaying them on screen as a result)
Answers
To answer your questions directly:
You store data in a db through Rails or another framework
Helios looks like it will connect your iOS app to your backend db infrastructure. Don't know how it works, but it looks pretty good
Your objective-C code gets the iOS app running natively on iPhone / iPad
I think you'll be okay with what you have here

How do I keep my database in sync with TICoreDataSync?

I've been working on this problem for a while now. Here's what happens:
My app is launched. It already has existing data in the core data store. It then connects to Dropbox using TICoreDataSync.
Then I connect a second device, which also has existing data. I connect it up to Dropbox the same way.
What then happens is that when I sync, it syncs data between the two harmoniously. Any changes i make on one device are sent to the other after a sync on both devices. The problem is, I want the existing data in the database to be uploaded to Dropbox and included in the sync, so both devices have all data.
How can I do this?
This is actually not how TICoreDataSync was intended to work. It will not merge those two store files for you, but will rather pull down the store file uploaded by the first device to the second device and then keep those store files in sync. From your description it sounds like you are skipping the whole store upload and download steps during sync manager registration.

where to store my data in appcelerator?

lets say we want to do a simple app for android and for this app we want some data. Those data when i test my example on my pc locally i have them in a file with json format.
lets say that the app doesnt need an internet connection so we cant send a request to a server somewhere.
Now if i move to the android device ( in my case the titanium emulator ) i dont have a server so i can't fetch my json data file.
So whats the secret ? how am i going to do this work ? how all those native apps work with no server, no database, not a way to fetch an xml or json data file ?
thnx
This page provides examples of three ways to work with local data: http://wiki.appcelerator.org/display/guides/Working+with+Local+Data
Application Properties
Filesystem Data
Local SQLite database
If you specifically want to work with JSON data, this example should be a huge head start for you:
http://wiki.appcelerator.org/display/guides/Working+with+Local+Data#WorkingwithLocalData-StoringJSobjectsasJSONinproperties
take a look at the kitchenSink examples, specifically the FileSystem examples
they will demonstrate how to read and write from the local filesystem of the device
filesystem.js in KitchenSink
as i see, i think you want to save some data locally right?
actually for me, i keep some simple information in the Ti.App.yourdata
such as
win.js
.....
win.name='your name';
Ti.App.name=win.name;
then you can use Ti.App.name for value of win.name anywhere
another way is use Ti.DB
that's local db
sorry if it's not answer you question :p im beginner too
Check out SculeJS, it's a pure JavaScript NoSQL database system designed for use in Titanium, NodeJS, and web based applications. The project is a rewrite of JSONDB.

Remote Backup User Data on iPhone

I wrote a few iPhone apps using Core Data for persistent storage. Everything is working great but I would like to add the ability for users to back up their data to a PC (via WiFi to a PC app) or to a web server.
This is new to me and I can't seem to figure out where to begin researching the problem. I don't want to overcomplicate the issue if there is an easy way to implement this.
Is anyone familiar enough with what I am looking to do to point me in the right direction or give me a high level overview of what I should be considering?
The data is all text and would be perfectly stored in .csv files if that matters.
Unfortunately, I don't think there's a good all-purpose solution under the current SDK. Here are some ideas:
If you only want backup, you could just back up the whole sqlite file to the server or over wifi, but you then can't really use it with anything other than Core Data (and you might even run into trouble with iPhone-Mac compatibility, e.g. between 32-bit and 64-bit types).
A very robust solution would be to implement cloud storage with a REST API and sync the iPhone and desktop app to the server (this is what the Evernote app does, for instance), but that is obviously much more work.
You could also manually convert your data to a .csv and send that to the server or desktop, but parsing it could be problematic (and you'd have to worry about the data getting corrupted). If you did want to go that route, here is a tutorial.