Making better chat apps with the "Any Component" blocks

It’s explained in the documentation here: Realtime DB by Firebase - Thunkable Docs

I will check that out, the issues am having now is whenever I left the screen, the previous chat disappears

It’s amazing,yes am having same issues as @itzvinie presently previous chats disappears whenever I reopen the app. @tatiang @muneer @domhnallohanlon @Scene

1 Like

You will need to provide a link to your project. Without seeing your blocks, we have no idea why it’s not working.

1 Like

Ok I will do that shortly

This is the link to the app
https://x.thunkable.com/copy/7a4d0710d58308418d1c8a4e5b581ea5

Firebase as a database repository will not delete records by itself. It is the way you coded the screen in your project that leads to this.

1 Like

So what do I do now?
Can you please help make corrections in there and share link,
Or probably also Note the mistakes made to avoid such mess again

1 Like

Currently, these are the two working blocks
image

As you can see, none of them actually saves the chat to Firebase. You only save the last input message to cloud variable Send_ChaT and what is showing on the screen is the result of cloning the screen components only.

2 Likes

Smile :blush::blush::blush::blush::blush:
You are such a genius,so I will simply do what now ?

1 Like

So I think that the ‘SAVE’ should come in the second blocking,after save is done_then the cloning should take place??:thinking:
Or can it be at the click of the SEND_CHAT BUTTON?

1 Like

This is a general question which is hard to answer.

You would first need to decide on what you want to achieve.

  • Do you want to design a chat app where users join a room and chat to each other?
  • Do you want tot design a chat app where two users can have a private chat (one to one)?
  • Or you want to provide both features.

The next thing is to design your Firebase database structure such as for one to one:-

Chat-DB
    chat-Header
         To-user
         From-User
         Message-List
             Date-Stamp(ID)
                 Sender
                 Message-Text

Now you can start coding your blocks accordingly.

This is just a simple scenario.

2 Likes

I appreciate your response and attention so far.
But for now all I want is a room chat

1 Like

For a room chat, your Firebase database structure could be:-

Chat-DB
    chat-Room
         Room-Code
         Message-List
             Date-Stamp( as message ID)
                 Sender
                 Message-Text

You will need to save every message under the correct key.

When any user runs the app and enters the room code, you should read your Firebase and display the chat messages under that room before giving the user the ability to send his/her own message.

1 Like

It’s more like I will be starting this fresh,how can I delete old variables

1 Like

Am so confused right now,which and which are actually Variables,can you please just shed more light on how to go about this structures you’ve pointed out…
Thanks for the rescue

1 Like

Hi @versatile
To help you with a good start, I modified your app to read from Firebase.
https://x.thunkable.com/projectPage/62bee1f46ab61900116b9ba3

You will need to supply the API key and the Database URL.

When starting the app you need to choose a room. If you don’t select a room, general will be chosen.

You will also need to supply a nickname to use in the chat.

If there are previous messages stored in Firebase, they will be listed in the chat area.

The project is not complete and that is not the intention. To use it properly, you will need to fine tune it.

As of now, you can use it with more than one user simultaneously and you should get the chat from other users in the same room.

Have Fun!

2 Likes

am blessed,big ups to you.i really appreciate this

1 Like

I noticed a bug in the project that it duplicates the chat history with every new entry. This is now fixed. You can remix the project again to get the updated copy.

To use it properly you will need to add a procedure/function to check the the nickname/ID entered is not already used.

Sample output

1 Like

Hurray, thanks I’ve been on it since+duties calls
It’s working but still trying to fine tune it

1 Like