Im using JSQMessagesViewController to implement chat to my app. How can I delete messages?
I found this method to handle deletion:
override func collectionView(_ collectionView: JSQMessagesCollectionView!, didDeleteMessageAt indexPath: IndexPath!) {
}
But I don't know how to delete message at index path.
It depends on how you are saving the messages l. In my own implementation I have an array of messages var messages = [JSQMessage]
So since you have that delete method you know which message needs to be removed so you should be able to call something along these lines
messages.remove(at: indexPath.item)
Now if you are using some type of backed this is where you would call the appropriate method from your API. You will most likely want to call collectionView.reloadData()
after it completes.
Hope that this helps 👾
if not could you share the code your are struggling with