I am having a simple JSON structure in Firebase console. I have a kind of chat app that uses this data to chat with other users. Everything works fine. But just sometimes, even after adding the value to Firebase with setValue, I cannot see the value in the console for a very long time(like around 3-5 mins).
For example:
For the above structure, I am adding values with below code snippet:
mFirebaseTyping.child("68_118").child("118").setValue(typingObject)
Now, it takes too long to update value to firebase. Sometimes around 3-5 minutes.
Does anyone have any work around this lagging issue? Any help would be appreciated.
P.S.: I tried with CompletionListener too, but the response only takes that time(i.e.: 3-5 mins). So does that mean this Firebase Realtime Database is not recommended for chatting apps?
Related
I have a collection in my Firestore Database with posts. Each post has some comments as a document in the collection comments in the main post document (screenshot)
In my Android app when I click on the post item I go to PostDetail screen and there I download comments.
I want to increment the value of timesViewed for each comment which has been downloaded and displayed.
Is it possible to do that? I want to do that in the most efficient way. I don't want to increment every single comment manually by sending a request timesViewed++.
I want to increment the value of timesViewed for each comment which has been downloaded and displayed.
If you're looking for something that does that automatically, please note that there is nothing built-in.
Is it possible to do that?
Yes, but you should implement your own mechanism.
I don't want to increment every single comment manually by sending a request timesViewed++.
Unfortunately, there is no other way. However, it is very easy to implement. You can use FieldValue.increment(1).
Unfortunately, such a feature does not exist in the RealtimeDatabase firebase and firestore to automatically increase a field.
But you can create a counter and retrieve the counter every time onResponse () or onComplete and increase it by 1, which is not recommended for 2 reasons.
Generates extra traffic, especially if the number of users is large
It is not reliable because someone can intentionally increase it
But if you do not mind a lot of traffic and you insist on doing so, do not forget to set rules in the firebase console to control the incremental frequency.
After updating the application, the data does not come to FirebaseAnalytics,
those that are Automatically collected events https://support.google.com/firebase/answer/9234069?hl=en The libraries associated with Firebase remained the same, the file and the project too (in the studio it says Connected), and the connection is the same, but the data stopped arriving (there were none custom events). It seems that something is interfering with sending data from the application to Firebase. I tried to debug the line mFirebaseAnalytics = FirebaseAnalytics.getInstance(this) To see what is inside mFirebaseAnalytics, but there is a lot of information that it is not clear where to look. Are there ways to programmatically find out if data is being sent to Firebase? Or maybe someone came across a similar thing, what else can it be, please tell me which way to dig !?
Are you developping a single page app? Firebase analytics take some time to show events.
Read it: How to track page view with Firebase Analytics in a web, single page app?
Working with Firebase from past 3 months made my data "fan-out" and managing redundant data day by day I am feeling as if I am over coding now.
I am typically making logging app. Logging Hours minutes. Here what it does.
Every user signup trough Google authentication.Data is saved in "/users/[users]"
Then they further create some Helper or workers who's time is been logged.
Workers are saved as "/workers/userID/[workers]
Logs : A worker is selected and his logs are added in two places
/logs/userId/[logs] (this is for calculating monthly stats)
/workder_logs/workerId/[logs] (this is for calculating per worker based stats)
This works fine for me..
But now I am taking this app from productivity app to collaborative app.
Where users can connect with each other and request or approve logs
Logs added by one users is reviewed and approved/rejected by other user.
This is what happens when a log in this new logic
User select a worker again which is now linked to a userid (typically linkedUser field in Worker class)
Log is added to /logs/userid/
Log is added to /worker_logs/workderid/
Log is added to /logs/otherUserId/
And once he approve it is added to /worker_log/otherUserWorker/
But before that I need a notification screen. This is where I am getting frustrated by firebase after so many days of work(I am also working on some other project with Firebase).
I want to query this for a single recyclerview.
Select logs from /logs/myUserid/ where logs.date is between 1dec16 to
31dec16 and { (logs.createdby="not me" and logs.status=unapproved) or
(logs.createdby="me" and logs.status=rejected) }
Point is I do not want to maintain further logs redundancies(putting in different buckets namely /log/approved etc and manage them). I am not getting any breakthrough when it comes to querying data in Firebase.
I also feel documentation is not so much helpful.
I'm writing an android application that has a search feature that needs to autocomplete from a list of stores. This list will only have up to a few thousand stores in it.
My current methodology is to send a LIKE query to the database every few hundred ms after the user has stopped typing and to populate the autocomplete list with these results.
Would using this method be stressful to the database?
It has been suggested to me that this wouldn't work because making continuous calls would be poor for users with a slow connection and that I should load all the stores into memory and filter from there.
At my work I ran into a similar problem a few months back. The contents of a text box filled by the user were supposed to filter their available options to choose from in a list of strings. The list needed to be updated every time the user typed a key so database calls to fetch records that matched their text were being made several times a second.
This ended up being wayy to slow to update as someone was typing, and this was only with several thousand records and with a server that was being accessed on site.
If you want to update as quickly as someone can type, making that many database calls simply won't do. Users will get pretty antsy having to let their phone buffer to type in some text.
In Short: Make one databse call and load it up onto the phone, and run your filter algorithm from there.
Regularly syncing the list of stores from your back end to the user's device and implementing autocomplete locally is the best way to go.
The JobScheduler API provides a flexible way to set constraints on your background syncing processes.
I working on my app that uses "The movie database API".
This app just parse a json from the API and gets each movie information.
My question is what the better way to that.
First alternative is to build syncAdapter, check for updates each day for example, store all movies information on local database and update the UI from database.
Second alternative is just retrive the information from network on each request and update the UI.
Can anyone explain me wich way is better and why?
Absolutely the first alternative !!!!!
let's Suppose your app is used by thousand of users and you have chosen the second one .....oh poor server :)
I usualy create my own local database and syncronize it each "x" interval time depending on the type of information : if I have, for example, a list o category that I know they are rearly changed than I syncronize them each "2 days" ....For data that can be different more often I use 20 minutes and so on. This just avoid stressing server if the user goes in/out from your app.
Bye