how to make realtime chat app using firestore with recyclerview - android

this app uses to store vendors and users and chat between them. I want to make an android chat app using recycleview and firebase firestore but the problem is that recycle view doesn't update properly so how to do that. data also get but after sending time not show instantly message I want to go back after that show message and also message not show proper order from firestore so how to do it.
message history also wants perfectly. please help to solve this problem this is my code.
This is the structure of the firebase firestore database
I want a simple solution to how to make a real-time chat app with firestore and recyclerview...

Look bro -
If u want to get real-time update using firestore then add
Snapshotlister then u get real time update..
2nd things that
If you want to make chat app .then
Don't go with fireStore because ur read and write count ll become increased
Due to this Ur Firebase bill will be high.may be u can't afford it.
And also it is not recommend to use firestrore to making chat app.

Related

group chat in flutter using firebase with a twist

Disclaimer: I have never worked with firebase or any other DB so my idea is pretty rough and I will be glad if u correct me in some of my assumptions. Also this is my first question on StackOverflow so I hope it will be detailed enough.
I am currently working on my project which is basically a group chat in flutter using firebase, where I should be able to create a new group chat(create a new DB in firestore) trough the app, let other ppl join(assign them to the new group chat DB).
The twist: If I send a message to the group chat I want other ppl to see a pop-up saying: "do you accept this message", no=> doesn't show / yes=> Shows the message but deletes it for others.
This app is nothing but my idea of how to confirm my theory and also learn a little bit more about both flutter and firebase, so please do not mind if it's useful or not.
Assumption: Each groupchat has it's own DB (Can I create a DB in firestore trough app / send request to?)
Question: Can I assign a specific ID to each message and choose and further edit who is going to be able to see the message trough the app(app_instance_1"I accepted the message so only I and sender can see it")?
Here's a great article for making a Flutter chat app: https://medium.com/flutter-community/building-chat-app-in-flutter-with-firebase-888b6222fe20. If you need more detail or help just write a comment.
About your assumption. Each app usually is connected to one database, and within the database, you can have separate documents to hold each group chat. You can also set up documents for each individual user to save the chats that only they can see. Within documents, you add collections that hold your data.

create private chat & group chat on different condition using firebase firestore in android

I have to implement chat functionality in my existing app using firebase firestore but there are 2 cases:
create private chat- in this case i have the recyclerview that contain user list while i select particular user then start communication in current user & selected user.
group chat- in this case i have food item list & each food item has user list who send request to that food item now i want to allow current user to create group chat by adding those user who send request to that food item.
how to achieve those thing.
There are many ways on how to achieve the Chat application. It will depend on how you want or prefer to develop your database and application in general.
Considering that, I would recommend you take a look at the below articles, for more information and steps on how to achieve that.
These first 3 are more related to your private chat application part, that I think should help you.
[Make-A] Simple Chat Application using Cloud Firestore Part 1 – Introduction
Firestore Megachat - Let's Build a Chat App
How to structure Firestore database in chat app?
This last one, I would recommend you take a look, as it provides more information regarding creating a Group Chat application with Firestore.
Group Chat with Firestore
Let me know if the information helped you!

How can I change content of my app after it is published without updating version?

I want to make an android app that will display mess menu of hostel. The menu will be changing every week so how can I change content of TextView once it is installed in user's phone .I considered WebView but I want better alternative . I think I need some cloud based service here . What are some good resources to achieve this.
Just do a Simple REST API and then every time you start your app call your api to retrieve the information, for example
yourdomaing.com/api/menu/getmenus should retrieve a Json with every item on menu.
You have plenty languages for making a simple rest api
check this related link
Examples of REST APIS
You can store your data (Text/Media) on firebase,It is very easy to start and then enable firebase offline functionality so that it is not required to download data on each launch of application.
Update data on firebase and add valueEventListener in your activity to get that data.
An alternative could be Firebase (by Google).
It's a free and real-time service. It allows you to change the content while the app is running. See "real-time database" and "A/B testing" in Firebase.

remove old data in Firebase

I know this question a lot here, But I don`t know about this. This is about chat app.
When message get stored into the firebase database. It would become bigger and bigger as time goes by, I want to delete it. and when should I delete this? I just want to left just only last 10 data. It means if I out the app and again go in, It appears only last 10 sentence and I know about the function limitToFirst and limitToLast (but this is not the delete thing.)
If I pay firebase server, you know, if database's data is large It will be more expensive. but I just want to leave just last 10 sentences at least.
when they did come back then they can see the last 10sentence and want to delete except for this. how do I do this?
I saw the answer using the date, but I don`t want that. Is that only answer? If I must do that when I get to delete them? When do I invoke the delete function?
I know how to do that almost, but when? If in the app, there are so many friends and I open the chat screen to chat my friend. That time should I delete them using remove function? How am I saving this for server payment?
I don`t want cost a lot. and I want them to be clear, not dirty in my Firebase database console. so want to delete them. Which is the I have to do? Which time is the best time that I should delete them? When open it ? or when close it ? or when users stop the my app.
You can achieve this in a very simple way. You can use the getChildrenCount() method on the node in which you hold the messages to see the exact number of messages. If you are using as an identifier the random key generated by the push() method, it's very easy to delete the extra messages. Because the records are by default order by date, you can easily query your database using limitToLast(limit) method and than delete the messages like this:
yourRef.child("messages").child(messageId).removeValue();
Another way to achieve this is to use Cloud Functions for Firebase.
Hope it helps.
you can use firebase functions to delete old data when new ones added to the database that is the best time, you can keep the last 100 messages or less.

What is the best way to change website contents without the user giving any trigger

For example, whenever someone "likes" your post in Facebook, you get a notification. You don't have to refresh your page to get the notification. Or whenever someone sends you a message in Whatsapp you immediately get it.
How do they implement that? Does it use Ajax to listen for database changes every second or so?
I want to build an Android application which should do something whenever the value of a remote database changes. Should I use a service to check for the database value every second and compare it to the previous value? Is this the best way to do it?
You could either setup a gcm service or use the native android service to hit your database at a fixed interval of time . GCM would be more efficient and would be recommended , if your app is an extensive real time sort of an app like a messenger or something
You should look into Google Cloud Messaging. But you will need a server to implement it.
https://developers.google.com/cloud-messaging/

Categories

Resources