Can I pre-cache data to work offline in mobile app using AppSync? - aws-appsync

I am developing an Android and iOS app that could be used in areas that have a very poor or no data connection. It is a requirement for the app to be pre-loaded with all of the data so it will work even if the app never communicated with the server, but it also needs to be able to update and sync when a connection is made. Is it possible to manually populate the AppSync (Apollo) cache database with data on launch and query and mutate it later? The app also contains several search and filter queries. Our backend API is currently using GraphQL.
I have seen this question, Is it possible to build offline-first mobile apps using AWS AppSync?, but it is a little different that what I'm asking.

The recommendation would be to hydrate (read: pre-load with data) a local SQLite database after install. SQLite is what the 'local cache' uses to persist data on the device.
Refer to this github issue for a code example of how to do this:
https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/160

Related

Need some clarification about Mongo Realm and Mongo Atlas. And App user data

I am new to app development and I've been looking into using MongoDB Atlas and MongoDB Realm. A few questions I couldn't find answers from their documentation, hopefully someone can clarify for me.
Is it correct to think Mongo Realm is client DB and it uses sync to the MongoDB Atlas, so if I make a React Native app using Realm, then user store/retrieve data from one device, and can pick up from another device (if they logged in with the same account)?
If point 1 is yes, then if I want to make a web app as well and skip Realm and only use Mongo Atlas, can I use the data synced from Realm? E.g. a task list created with my React Native app in Realm and synced to Atlas, can I create a web app and query synced data stored in Atlas direct say with Mongoose?
If point 2 is true, how can I access app user from Atlas, it seems it only exists only in Realm, what's approach here?
Final point is, for this kind of cross platform app, what's the best approach?
Many thanks,
I am currently working on implementing an app with the setup you describe.
Is it correct to think Mongo Realm is client DB and it uses sync to the MongoDB Atlas, so if I make a React Native app using Realm, then user store/retrieve data from one device, and can pick up from another device (if they logged in with the same account)?
Yes! You can try this easily with the Task Tracker App by MongoDB Realm Sync
if I want to make a web app as well and skip Realm and only use Mongo Atlas, can I use the data synced from Realm? E.g. a task list created with my React Native app in Realm and synced to Atlas, can I create a web app and query synced data stored in Atlas direct say with Mongoose?
Yes! - Realm Sync does not support React Native Web as far as I know, therefore creating a Web App with React or Next.js is a good alternative as MongoDB Atlas data synced from mobile devices via Realm Sync can be easily be accessed in this way. I am currently looking at the following approach: How to Integrate MongoDB Into Your Next.js App
how can I access app user from Atlas, it seems it only exists only in Realm, what's approach here?
Try the above mentioned example app with a few users and this will become more clear to you. In this case the MongoDB Atlas database will be 'partitioned' by userID making it easy to get just the data you want for the web app. Look into Partition Atlas Data into Realms to understand this more fully.
for this kind of cross platform app, what's the best approach?
Well what is the best approach is difficult to answer as the question is too broad, and it depends a lot on what the app is for and how it is used.
Personally I have good reasons for choosing Realm Sync, as I require offline-first capability. I am building a React Native iOS/Android app with many users having their own data. Therefore I am 'partitioning' by userID. My main use case is mobile and the web app is merely intended to support easy data entry and editing on a laptop or desktop. Therefore not all features of the mobile app need to be replicated in the web app. This is just my personal approach.

Cloud Data Storage across devices without Login (iCloud, CloudKit)

I do have a background as a native iOS software developer.
We had a couple of apps for iPhones and iPads that used CloudKit to sync data between the same App installed on different devices of a single user.
It was used for simple things like favorited items within apps that did not have any login or account mechanisms.
How would I achieve such a functionality in flutter?
Havent found any iCloud related plugins for dart/flutter.
Thank you!
I do not believe there is a direct way to access the CloudKit from dart/flutter, however, there is nothing stopping you from trying this architecture.
Build a (PHP?)/CloudJS application on a webserver to serve REST-ful API calls that send/retrieve data from CloudKit Containers (CloudKit Web Service Reference). You'll want to set up some server-to-server authentication for this to work.
Posting/Fetching data via the REST API calls from dart/flutter. There are many libs that facilitate this and author (BRIJESH) over on androidkt.com offers an interesting walkthrough of some options.

Accessing Database using node.js in iOS

I want to create such a application in which my iPhone will have the UI for entering the data for the employees. After clicking on the post button data should be saved on the sqlite database and I also want to retrieve the data on button click from the database. I want to use node.js for communicating between my iOS app and the database. Since I have never used node.js before, please give me some links where I can study the sample applications.
I am not an iOS developer but I would make a REST service in Node.js that can sit between your Iphone app and your database. You most likely are going to want to have some form of authentication on the service.
Also does it have to be sqlite? There are databases that can understand HTTP. If you use CouchDB (there are others) you can let your app talk directly to your database. That means you can leave out Node.js completely. You can go even further and use a service that will provide a back-end for you. Something like parse.com (there are others) will do this for you.

Need iOS Database Cloud Design Tips

I have an app that uses an SQLite database. With the advent of iCloud on the rise I'm trying to figure out a good architecture for syncing data between devices. So lets say my app runs on an iPhone, an iPad, and a Mac. How can I keep data in my DB up-to-date on all devices?
My first thought was, I can put the database in the cloud and send transactions. But the device may not always been online and the users need their content at anytime, so that wont work. My other thought was to continue using the local db, and then when a connection is made, to send the cached data to the central db. The problem is I have no ideal where to even begin on something like that. How would I know which data has been sent and not sent, which data to actually send when a connection is made, etc.
So this is my question (we don't have to get into iCloud specifics), using an SQLite database and iCloud (or any storage medium), how can I sync data between multiple devices, but still have the most recent data stored locally on the device?
You might want to checkout Couchbase Mobile. This would help with the synchronization you are looking for.
If you have a significant investment into CoreData, then you may want to look at writing your own NSIncrementalStore to support writing data to and from a key value store.
iCloud is only going to be a good solution if your data is sandboxed to a specific user. If you have multiple users that want to view the same data then it won't work.

iOS app to access database from my own website

I own a JSP website for listing books stored in my own database in the same website. I'm planning to develop an iPhone app to access this database and display book list and book details.
My questions are:
If I have to use web services, where
should I start to develop these web
services using eclipse.
How to access these data and display
them in a list.
I want to cache data extracted and
store it locally in iPhone, so when
no Internet connectivity available
the user can view these data
offline. Is there a database engine
embedded in iPhone to sotre such
relational data.
Thanks you all,
Develop the webservice with what you know. PHP, Python, asp.net, java.
Access the data using HTTP GET POST methods. Many application are using the json-framework.
iPhone as the sqlite3 database embed in it operating system. You can find plenty of tutorial on the internet.
1 & 2 Define the services you are going to provided from you website, choose a web service protocol, JSON is generally easy to use, so does xmlrpc.
3 Use core data to cache it locally, if no internet connection, you can fetch the data from core data