I have implemented MessageKit in my app. Now I need to get indexPath of message. I used following code:
func didTapMessage(in cell: MessageCollectionViewCell) {
//Call Method to Show Action Picker
guard let indexPath = messagesCollectionView.indexPath(for: cell) else { return }
print(indexPath.row)
}
But when I print this row number it is always returning 0 I am not getting where I am wrong.
Have you tried checking the section as well? I believe they use a combination of sections for each message and rows for different parts of the message (top label, main message, bottom label, etc)
You can use indexPath.section
MessageKit is section based, meaning each cell is in it's own section (as others have pointed out above). You will need to use indexPath.section
Most helpful comment
Have you tried checking the section as well? I believe they use a combination of sections for each message and rows for different parts of the message (top label, main message, bottom label, etc)