Making a Chat App

I’m making a Chat App. I already looked through popuar lnks on the discussion already and none really touch on my problem so I’d like to put it here for some help.

Basically, theres 2 apps. Student App and Teacher App. Students have assigned techers through Firebase and vice versa for teachers. The problem is that when a message is sent, it is not appending to the Firebase and therefore not showing in the sutdent’s App, or even at all in the firebase. yet when I make edits in the firebase myself and add/remove messages, it shows in both apps. I’ll send pics of what I’ve done below and a Pic of my firebase part thats relevant.

Student App Code:



Error on student app :

Teacher App Code




Teacher Error :

Both have generally the same Code because the Firebase is shared. just that its not appending to the databse is the main issuse. None of the guides on the community thing or online show how t properly work around with the firbse databse,

My firebase :

So yeah. if any other info is needed would be nice. I don’t wanna redo it from stratch because i put alot of work into it and this is just a single issuse that i’ve spent like a week on. Help would be appreciated

Hi YXProgs,

I see that no one has responded for a while, I would like to help you but I can’t quite understand what the problem is, can you simply show me the

  • function you call
  • the result you get
  • the result you would like to get.

Fair.

I’m calling 2/3 functions. The DataChanged and GotValue.
here are pictures of their contents.

Got Value :



Data Changed:


When I send a message it does i nthe chat veiw in app1 however it does NOT append to firebase and therefore doesn’t show in App2, its a texting App.

What i do get is:


and an “Invalid JSON object in databse”

So the problem only occurs when you send the data from the app, well then you just need to fix the Button1.Click block.

Before sending the data to Firebase, did you set the Bucket?
And what you’re sendind as Tag?

I set the Firebase Bucket in the Desinger. Do I need to re-set it in the code blocks? I’ll try that tho, never thought of that.

What im sending ad tags is in the pics. Essentially this

It seems correct to me since i was going to keep the messages as a list and just append each new message however I’m not sure now

No no, you did well to set it up directly in the designer, but what does global studentID contain? Just ‘student001’?
The path must be yourProjectBucket/messages/student001

immagine


or

immagine

OHHHHH, ok I see. My project bucket is not like that. I tried learn from the doc and came to the conclusion that my bucket should be


I’m gonna try that out.
Thanks alot

I’m tryna understand this before I do it.
Why do have that variable “messageNumber”? when a new thing is appended does it not automatically increase the numbers and make a new one? or do i need to set up a loop/logic to increase and add the message number for each value stored?

Figured it out, its working, in terms of adding the message to Firebase. I should be able to do the rest in makign it visible myself. thanks alot

1 Like

:partying_face: :partying_face: :partying_face:

wow, and if possible, share the soln with us :rocket:

Sure.
Here are the final blocks for the .ButtonClick ;
Student App :

Teacher App :


I added the followign ID Procedure to both :
image

And now it actually adds the typed messages to the Firebase when its typed in either App.
Evidence :

I just need to clean up the extra apostrophes and a few more bugs but p much done the biggest hurdle. I hope

2 Likes

Sorry, I was out and couldn’t answer well on the phone, I found a solution for you :partying_face:.

Since each firebase.dataChanged returns all the data from the bucket, you can simply save the list, use add item to list, and send back the entire node with the added data.
Plus, there are no annoying double quotation marks.

use a Web.putText


It’s not ideal from a technical point of view, but it works well!! :grin::grin::grin:


Take a look at this guide from the undisputed master
:raising_hands::raising_hands::raising_hands:@TimAi2:raising_hands::raising_hands::raising_hands:

But I wholeheartedly recommend you explore the entire site,
because it’s truly a source of :brain:wisdom:brain:.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.