Is there a way a way to track flutter application is opened or not?
Oh, so basically. I was so stupid asking this.
It is an easy problem by using the database, either the SQLite, or query from server.
retrieve the data from database (tracking column)
increment that by 1
finally update the database.
Related
I'm trying to build a flutter app
which shows a chart that reads data from a MySql database (a table)
I want to update the chart
when the data in the table is updated
without manually refresh the page
the table is updated by a script run by a cronjob (hourly, for example)
the first way that comes to my mind is
using flutter's Timer.periodic function
so that the app can periodically check the table if there is any update
but, in this way, I can not get a real-time update (to do so is seriously expensive)
So the second way I could think of is
using WebSocket
however, I'm sure if it's possible or an appropriate way to do this.
because I don't know how to do that.
should the app (flutter) websocket commnunicate with Mysql?
should I implement backend websocket to let flutter know the update?
Using WebSocket is the best way to implement real-time update chart application?
Or are there any other ways that can solve this issue?
Thank you for whoever answer to this question.
You can use the websocket to let the application know about the new updates. For example, if x device inserts a new record you can send it to the websocket and listen for it from the y device. During this process, you can insert that data to the database from the server side and you don't need to fetch data again and again to achieve real-time.(you have to build logic to listen and update the UI as your needs) Rather than MYSQL, it would be more efficient if you use the mongodb with nodejs API for this. There are a lot of tutorials about websocket implementation with flutter.
Also you can use firebase for real-time communication. You don't need to worry about the server side if you use the firebase. Keep in mind to follow recommended guidelines from the documentation since they count the bill for each request you send from your application.
Another option is Appwrite. As I heard, it is the best replacement for the firebase and since I haven't used it yet I'm not going to say more about it, but you should try it if it is a match for your requirements.
I'm using Cloudant and I'm struggling to pull/replicate 600 documents from server to my iPhone. First, it's pretty slow because it has to go one-document-at-a-time, and Second Cloudant was giving me "timeouts" after the 100th-or-so REST request. (I have a ticket with Cloudant for this one, as it's unacceptable!)
I was wondering if anyone has found a way / hack to "bulk" replicate when pulling. I was thinking, perhaps it's possible to "zip up" all of the changes, send them in one file, and fast-forward the iPhone database to the last-change seq.
Any helps is great -- thanks!
Can you not hit _all_docs?include_docs=true to get everything in one shot? http://wiki.apache.org/couchdb/HTTP_Document_API#all_docs
I don't know couchcoccoa but it looks like the API supports this: http://couchbaselabs.github.com/CouchCocoa/docs/interfaceCouchDatabase.html#a49d0904f438587b988860891e8049885
Actually, why not make a view. Make a view that gives you your list and make sure your id is there. With your id, you can then go to the document and get all the rest of the required information that you need in order to update it if you need to.
There really is no reason you would ever need to hit every document individually. They have views and search2.0 for that. Keep in mind you are using a cloud based technology. This stuff is not sitting in your basement, you can't just hit it a million times per device in a few seconds and expect anyone to not notice and/or get upset (an exaggeration, yes I know).
What I do not understand is that you are trying to replicate it to an iPhone? Are you running apache and couchdb in your app? Why not just read the JSON data and throw it into a database. or just throw it into a file if it updates that much and keep overwriting it. There is so many options that are a whole lot less messy.
I created an iphone application that uses database. Here is the problem, this application should work offline. I am not going to use a remote database but i have to update these datas every 2 month. How can i update the datas that was already stored in application? What is the best way and keywords?
Thank you.
The question isn't the easiest to decipher..... but from what I gather...
If you don't have a web service to call (I guess this is what you mean by remote database??), then you're only option is to release an updated version of your app every 2 months with an updated database.
I am trying to save some data from GPS to a local database. First time when i am entering data, it saves all velues. But after clear the data entry sheet it not saved in database. When i quit the app and again save some data, it enters easily. I m confused what happens in my app ? Any help really appreciated.
Thanks in advance.
Try to debug your app. It seems you are passing some wrong arguments. You need to debug your app. You can use FMDB for all the sqlite purpose. It is very easier to use and very easy to manage.
Have you commited the changes in the DataBase?
Before you decide to use database (SQLite) , make sure you really need a database. If all you need is to persist data and retrive it back (and not querying) , try to do archiving / serialization. See Serialization vs. Archiving? for quick info on them
If your requirement is to have a database, #Rahul's suggestion is the best.
I have a product database which I want to distribute to an iphone user application. Its data is stored in an SqlLite database.
What i want to ask is: If i update one products' price in the database, what is the best approach to update the users copy of the database in the iphone application ? I don't want to send the whole database time to iphone users.
If i send only updated products every db will be different on each iphone after some time.
I am pretty confused.
Any idea will be appreciated.
Thanks for your help
You could use a global revision Id for your database. Each item in your database would additionally include a field which keeps track of the revision they were last updated at. This is much like the way subversion works.
Whenever you update one or more fields in your central database you will increment the global revision number as well as the revision number for each of the updated entries.
Your iPhone database copy would then have to keep track of its own revision. Whenever it connects to the main database it can then ask for changes made since its own revision.
Eg. if the main database is at revision 1234 and the iPhone is at revision 1222, it would. Then receive the updates corresponding to 1223, 1224, etc.
Since the iPhone is designed to connect to the internet, why don't you get the iPhone user application to download an updated price list from the internet (your website) each time it opens, or every week, or similar?
update:
If your database is large, you could track updates to your database with a version number, and create 'patches' to your database in the form of SQL statements, to move from one version of the database to the next.
When the user application connects to your website, it can look for the appropriate patches to update to the current version, and download them.
This should reduce the amount of data downloaded to the minimum, especially if you compress the patches (using zip).