charlottesite.blogg.se

Flutter firebase chat app
Flutter firebase chat app














Since I did not know any mobile app development technologies, this got my attention as learning this would mean I can build apps for multi-platforms without having to learn multiple languages or frameworks.

#Flutter firebase chat app code

It is a Object oriented, garbage collected, strongly typed language that can compile to JS or Native code directly. Flutter uses a programming language called Dart, which is similar to combination of C++ and JS. the field inside of the roomId would be a connection between of the 2 user for accesing the message that've been send to db.Flutter is an open-source mobile SDK from Google to build native applications for multiple platforms from a single codebase. To be sure that random uid inside of chats collection is a room id that you should register in your users/doc/chats/ collection. after that you could create a chatroom collection that look like this put the the field exactly look like that. only put the roomId of connection that been made when user trying to send a new message to other user. You should create 2 collection for the db, the users collection would only save user data and in the chats collection inside of the uid is saving the chat room id that would be look like this So if you want to create the seen function you could made the database structure look like this first This is quite exploitable, there is no cloud function trigger on documents "onRead" that could help me move that logic outside the client, so what is the solution to make this also secure? If I manually write to a document and change the boolean value of some "isRead" field from my client, the client could easily skip that line of code and break my whole seen system, they could read messages without sending the seen signal just with a break point. Maybe my chat model is not really fit for what I need, how should I tweak it?Īnother problem is that I do not know how the "seen" signal should be sent. I am asking for guidance on how I should go about the architecture of such a chat using Firebase.

flutter firebase chat app

If I would have to mark each message document in particular with some "seenOn :timestamp" value, that would mean that if the user is reading 200 new messages, there are 200 new writes on each document, which seems too much to me, there should be another way.

  • I would like to create a system which is not write intensive.
  • If I were to call a cloud function which fetches the messages and somehow marks them as being read, that would break my app, as I need a continous stream of live message data for the chat to feel good, I can not stream data from the cloud function.
  • I can not come up with a good solution to this, my main 2 problems are:

    flutter firebase chat app

    I want to create the "seen" functionality, inherently I want the user to see what conversation he read or not (which ones have new messages, like instagram chat or discord) The message document is basically the message text and when it was sent and who sent it. Basically that's the structure col: ChatsĪnd this is how I get the messages inside the Chat Screen.

    flutter firebase chat app flutter firebase chat app

    The way it works in Firebase Firestore is really simple, I just have a conversationId which represents the documents where there are the messages, all of the users have a list of their conversations, when they tap on a conversation, a new screen pops up where they see the messages based on data from the stream of the "Messages" collection that is under the conversationId document. I am building a chat app using Flutter and Firebase.














    Flutter firebase chat app