Download the finished project and compare your code with this code.
Was the solution for me.
Still one issue. Photoās load on the simulator when added trough the chat. But in de iPhone nothing happensā¦Perhaps i missed something in the plist file.
images first load but now they donāt and they donāt present in my iPhone.
But they do in the simulatorā¦?
great tutorial as always!
one question: how can we reduce the image data?
thanks!
Really great tutorial! I was able to achieve similar functionality in no time thanks to your tutorial.
As side note, in the āsend imagesā section, within the code handling photo from photo library
there is a code line:
let path = "\(FIRAuth.auth()?.currentUser?.uid)/\(Int(Date.timeIntervalSinceReferenceDate * 1000))/\(photoReferenceUrl.lastPathComponent)"
that generates a weird url back in the firebase storage due to unwrapped optional.
I quickly fixed it by replacing it with:
let path = "\(FIRAuth.auth()!.currentUser!.uid)/\(Int(Date.timeIntervalSinceReferenceDate * 1000))/\(photoReferenceUrl.lastPathComponent)"
force unwrapping it. Of course this is the faster solution but not the safest one.
Thanks
Thank for this. One question: Why do we not have a capture list in the logging in section? We are using self in there, should we not do an unowned?
Sir, i need same firebase chat tutorial for android. I have searched, your url redirecting to here only for iOS.
Firebase vs. Firebase Cloud Messagingā¦
It seems from my Googling that this August saw the release of FCM, suggesting, if I understand correctly, a possible alternative to using Firebase Storage and Firebase Database for chat. Any thoughts on the pros and cons of one versus the other?
Yeah, FCM (Firebase Cloud Messaging for those following along at home) is more complex. It requires you setup your own app server that adheres to their protocols. So itās not a fully hosted solution like Firebase Storage et al.
Ahh, thanks for illuminating this confusing subject. Thinking proper Firebase Storage, etc. is where itās at then. Hoping it doesnāt disappear like Parse or soar up in price.
There is a retain cycle in the project. When you create the ChatViewController it will never be deleted from memory. You have the deinit method but the method is not getting called. I also checked it via Instruments Allocations. So far I donāt know how to fix it, but itās a serious bug. Any ideas?
Hi @aetsyss, it looks like youāre right. Well spotted! :]
Iāve just had a quick look and canāt see anything obviously retaining the ChatViewController. Iāll try and take another look over the next few days, but Iāve got another tutorial on the go and should be spending my time on that one at the moment!
In the meantime, if you find the problem please do let me know and Iāll update the tutorial. Thanks!
Hi @tomelliott,
I managed to fix the retain cycle by placing [weak self] before all blocks where I access self in the ChatViewController.
Ah-ha! Iāve just confirmed with a quick change and that fixes it for me. Thanks for debugging @aetsyss! :]
Iām somewhat surprised those retain cycles keep the view controller around indefinitely. As theyāre basically just async API calls Iād have thought everything would die eventually when the calls either complete or time out (as the blocks will die), but clearly you canāt rely on that. Iāll take a closer look over the next few days - maybe one in particular is playing up.
Glad to help you!
I keep getting an error: no such module found āJSQMessagesViewControllerā
pod use_frameworks!
pod āJSQMessagesViewControllerā
Iāve update the pod, tried to do a fresh import of JSQMessageViewController.
Anyone have any expert advice?
me too the same issue:
no such module: JSQMessagesViewController
https://drive.google.com/file/d/0B86KWEseOAWKYXBUOFdidWVzcDA/view?usp=sharing
I am having a crashing problem!! PLEASE HELP!!
https://drive.google.com/file/d/0B86KWEseOAWKYXBUOFdidWVzcDA/view?usp=sharing
I am having a crashing problem!! PLEASE HELP!!
Hi, looks like uāve got corrupted data. Try this to handle:
private func observeChannels() {
// We can use the observe method to listen for new
// channels being written to the Firebase DB
channelRefHandle = channelRef.observe(.childAdded, with: { (snapshot) -> Void in
if let channelData = snapshot.value as? Dictionary<String, AnyObject> {
let id = snapshot.key
if let name = channelData["name"] as! String!, name.characters.count > 0 {
self.channels.append(Channel(id: id, name: name))
self.tableView.reloadData()
} else {
print("Error! Could not decode channel data")
}
}
}
)}
Great tutorial TIm! Couple of questions:
-
With anonymous access authentication enabled on Firebase database, how do you define database rules to prevent public access to the database?
-
How do you add a badge āblue dot like emailā to channel for unread messages?
Thanks!