Insert Comments
Instagram Firebase
Now that our interface is ready for text input, let's begin the process of inserting comments for the user that is currently logged in. We'll be appending onto a comments node in Firebase to make the retrieval fast and simple. The three properties we'll need to keep track of are the comment text, creationDate, and user id.

Comments (10)
josephlausf
6 years ago
FYI, there is something called FIRServerValue.timestamp()
stonypig1
6 years ago
hello, if i don't have navigationcontroller, what else can i use to send the data out ?
stonypig1
6 years ago
i mean instead of push in navigationcontroller, i googled online they use .storyboard instantiateviewcontrollerwithidentifier will do the same thing? i tried it, but can't make it work, must be something wrong
Brian Voong
6 years ago
fahad
6 years ago
Hello Brian, If ever wanted to implement a notification..how can i change the badge value in the TabBar for the right user,,,do i access the recipient device??
Brian Voong
6 years ago
Derik Malcolm
5 years ago
Hi Brian, For some reason when tapping on the textField and going back to HomeController, the inputAccessoryView we created reappears in HomeController and covers the tabBar. I've done exactly as you did to resolve this but I'm still having this bug occur.
Derik Malcolm
5 years ago
I found what's causing it. It had to do with tabBarController.tabBar.isHidden being set. I removed the viewWillAppear and viewWillDisapear and set hidesBottomBarWhenPushed = true when pushing the CommentsController.
florianml
5 years ago
Hello Brian, I had a question. To allow users to reply to comments, I've structured the Comment struct to have a toId and fromId property. I was wondering if it's ok to store the comments in firebase like you've done in the video or should the correct way would be to do some sort of firebase fanout? If the latter, how would I go about approaching it?
sezertunca
5 years ago
Hi Brian, If I put NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil) to viewDidLoad, everytime I load the comment view keyboardWillShow gets called even though I have not clicked on the textField yet, how can I disable this? Thanks.
Jaylon22
5 years ago
Hey Brian great tutorials i love them but i have a bit of an issue, i get this error message 2018-09-03 22:28:19.215019-0500 ElohePrototype[1220:456307] *** Terminating app due to uncaught exception 'InvalidPathValidation', reason: '(child:) Must be a non-empty string and not contain '.' '#' '$' '[' or ']'' when i try to submit the comment, it saying the postId has one of those string could you please help me brian, than you and have a bless day.
Jaylon22
5 years ago
When it printed out the post id it was empty to add to this question.
DHM
5 years ago
also me any solution ???
jds292
3 years ago
Have you solved it yet? I faced the same problem.
DHM
5 years ago
Hello brain thanks for ur amazing work , i have one issue i can't get the post id it shows empty and give me this issue [ Must be a non-empty string and not contain '.' '#' '$' '[' or ']'' ] thanks
Brian Voong
5 years ago
DHM
5 years ago
thanks for your comment , unfortunately i'm using the storyboard so i'm getting the post id while i'm on the home controller but once i moved to the comment controller i lost post id ( in the IBAction of the [submit button] do i need to put someting on the sender ? to get the post id from the home controller ? )
Brian Voong
5 years ago
ncytimothy
4 years ago
For whoever has the issue with authentication, yet again. These rules worked: "rules": { "comments": { ".read": "auth != null", ".write": "auth != null" } } }
Dino32
4 years ago
Hi Brain! Please give my a tip, how do I make the text disappear in textfield after clicking on "submit" button ?
Brian Voong
4 years ago
Dino32
4 years ago
Thanks Brain! I Used command like "self.commentTextField.text = nil" in handleSubmit() function. Is it proper way?
HELP & SUPPORT