aslanyanhaik / Quick-Chat

Real time chat app written in Swift 5 using Firebase
MIT License
1.84k stars 360 forks source link

How to check the message was read by receiver user or not? #80

Open StellarKuldeep opened 5 years ago

StellarKuldeep commented 5 years ago

I want to check the receiver read the sender message or not and as per that I want to show/hide some content in my messageCell.

I found that current code finds the conversation was read or not by below code but I'm unable to find the code that will identify that particular message was read/unread in conversation

guard let id = conversation.userIDs.filter({$0 != userID}).first else { return }
        let isRead = conversation.isRead[userID] ?? true
        if !isRead {
            nameLabel.font = nameLabel.font.bold
            messageLabel.font = messageLabel.font.bold
            messageLabel.textColor = ThemeService.purpleColor
            timeLabel.font = timeLabel.font.bold

            vwNewMessage.isHidden = false
            constraintHeightOfNewMessage.constant = 24.0
            constraintTrailingOfLatestMessage.constant = 50.0
        }
        else {
            vwNewMessage.isHidden = true
            constraintHeightOfNewMessage.constant = 0.0
            constraintTrailingOfLatestMessage.constant = 10.0
        }
}

It will be very helpful to me if you guys give me some suggestion to do this.