I can't seem to get new messages sent from new user or new message sent from users already in tableview to go to the like with most messaging apps. I've ask this question before and tried to follow the directions in a link that someone kind enough to send me (How do you properly order data from Firebase chronologically) but I still can't get the desired effect no matter matter I try
func getChatsFeed(){
//following the links instruction "timeStamp" is suppose help return fireBase children in reverse order. "atValue: time" is a value for the time when my viewDidload.
let queryChats = Database.database().reference().queryOrdered(byChild: "timeStamp").queryEnding(atValue: time, childKey: "timeStamp")
queryChats.observe(.childAdded) { (snapshot) in
if let snapvalue = snapshot.value as? Dictionary<String,Any>, let
sender = snapvalue["sender"] as? String, let receiver =
snapvalue["receiver"] as? String, let message = snapvalue["messageBody"] as?
String, let key = snapvalue["key"] as? String, let timeStamp = snapvalue["timeStamp"] as? String{
let newMessage = FeedMessage(sender: sender, receiver: receiver, messageBody: message, key: key, timeStamp: timeStamp)
feedUpdate.append(newMessage)
self.chatsTableView.reloadData()
}
}
}
The link I included received a respectable amount of praise for being solution a to a lot of StackOverflow users problem so maybe I messed up somewhere, being not fully in the know of all the different Firebase methods, this could be the case. Any pointers anyone?