I am using Flutter for the app and Django with Postgres for my backend APIs. I want to update the data from API in-app to update in real-time, what is the best way to do it. I went through a lot of blog posts and SO answers and have got the following solutions, Any better solutions would be appreciated
Websockets - difficult to scale
Refresh APIs after every n seconds - Difficult to scale
Firestore in build functions but I don't want to migrate to firebase.
Are there any better solutions? I want the solution to scale to many users so please let me know the best solution for this. Thanks
Update:
I have two data sources, one is the flutter app itself and another is a web dashboard, I want the data in the app which is a listview to get updated whenever new data is added from the dashboard in real-time. The data in the app is a listview that should be updated in real time with new records from the API.
Don't know if this is good solution, but you can try to use FCM from Firebase (you wrote only about firestore/real-time database).
Every time app is in reasumed state it can register token in your backend, and every time web dashboard is being changed, server can send push notification to the app with data/trigger to fetch data.
WebDashboard -> Backend -> FCM(with trigger/ full data) -> Mobile
Related
I am working on a football scores application. How am I supposed to manage the live scores?
We have our own api, which is getting the data from a paid api. I know one method is to constantly hit the api after, let's say every 5 seconds, but is that the correct method? Or is there any other way? Thank you in advance.
There are several options for this type of functionality.
The first is to query the server every X seconds for fresh data (like you described)
The method I like better is using web sockets or other form of bi directional communication with the server that push the client the changes every time fresh data arrives from the 3rd party API or on some other logic you decide.
you have to use the Realtime database for the live score app. Websocket can send the data constantly and you don't need to call API every 5 seconds. Follow This Link to know about the Realtime Database. When there is any update in your database then the app will auto-refresh the data and show you the current score in your app.
Constantly hitting the API is not a good practice, this can hang your mobile.
I am trying to make an app in which I am going to use room database for offline data caching and using NodeJs and MongoDB as a backend service.
What I am going to do is when app first opens it fetches data from server and stores in room database from where it shows in database.
My problem is whenever some new data is updated on server how would I know whether it is available in room database and when to fire server request.
Someone please let me know how can achieve this any help would be appreciated.
THANKS
You are going to need to implement some sort of routine where you can check and validate (update) the data. However, this will depend on the importance of the data and rather if it should be updated and how often.
These are some of the solutions you can look at:
Long/short polling - Client Pull
WebSockets - Server Push
Server-Sent Events - Server Push
I would probably use some sort of real-time communication (web sockets) or use a real-time database to notify the app of changes when something needs to get updated. That said it would also depend on the technology, for instance, Firebase already offers offline caching.
You can achieve this functionality in multiple ways
Configure firebase notification in your app, whenever any server side data update happen just trigger a notification, based on that you can call api and store data in room.
Maintain some version code related to updated server side data in your api, based on that version code you can write logic for storing data in room.
if the application receives its data from remote server then we should save our data in the local database and have our UI load data from the local database for better UX right? Our UI should not load data from servers directly it will result in bad UX. Now my question is I am developing an e-commerce application and it’s data is very dynamic it can change anytime. The product can go out of stock, it’s price and the discount amount can change etc. So how to keep up with it. If I refresh local database every time user opens application then what will be the benefit of the local database. If any of you had faced the similar situation or worked on any e-commerce applications then please me suggest me better ways. Any help would be appreciated. I do not know if this is a right platform to ask this questions.
There are some solutions. You can use push notifications using Parse, for instance, when your MySQL changes. Or you can use JobManager to enqueue custom synchronization tasks. I recommend you to see this video and check out the video project: https://github.com/yigit/dev-summit-architecture-demo
This reflects your problem very good and it is a very nice solution and, the most important, it is developed by a Google employee.
I hope it helps you!
I'm trying to move an android app project from Firebase to Azure, and I've been working through the simple ToDo app tutorial on the Azure website:
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-android-get-started-offline-data/
I've been using this tutorial to try to understand the basic techniques involved in retrieving data from an Azure SQL server.
As it stands, the sample app refreshes local data when the user clicks a 'refresh button', by using:
mToDoTable.pull(null).get();
(Where mToDoTable is a MobileServiceSyncTable.)
I want to change the app so that local data is refreshed automatically whenever server data changes: the user shouldn't need to click a refresh button.
I'd expected this to be straightforward, and that it would probably involve attaching a listener of some sort to mToDoTable.(It works in this kind of way in Firebase, and it's easy to do.)
My problem is that I can't find any guidance on how to do this in Azure: I haven't found anything in the tutorials, the documentation, or via extensive Google searching. This leads to me to think that I'm missing something obvious (not unlikely since I'm completely new to Azure, I have no SQL experience, and I'm fairly new to Android in general). Any help much appreciated.
I don't have the answer like "no, there is no built-in mechanism" or "yes, there is a callback function or a trigger that will do what you want", and when i implemented some project in a recent past, i could not find such out-of-the-box solution. Pretty sure that there is no mechanism, however.
What i did in our project was to poll the backend using Exponential Back-off and event-driven approach (if-user-opens-then-poll-the-backend).
There are a lot of tutorials how to do that like that.
For example my application contains some quiz and I want to know the results from each user who installed the app. Is there any way to collect these stats?
Yes.
Use for example the Parse Library. https://parse.com/docs/android_guide. It's very easy to set up.
When you have set it up and read their guide, you'll be able to save data very easily. I had mine up in about five, ten minutes and I can now save complex data.
The upside of using a cloud based solution (Parse is cloud based) is of course that you won't need your own backend (server and database). You won't have to code your backend script/servlet either.