I am using https://github.com/jessesquires/JSQMessagesViewController/issues/1820 this library for chat application. By using this libary I am able to send images and video, but my app needs to send one view with some button and text. Like when user sends some text it will appear to others as text and button and then when somebody clicks the button one push notification will be generated. I am not able to figure it out how can I achieve this.
Here is screen shot how I want my custom view to be. It has some text user has typed and has 2 button for accept and reject.
I would suggest that you create your own custom view for this. You can use the
JSQIncomingCollectionViewCell.xib
orJSQOutgoingCollectionViewCell.xib
as a template for your self.CellWithConfimationButtons
In your ChatViewController i.e. what ever you called the view that is a subclass of 'JSQMessagesViewController'. Add these two lines
self.collectionView.registerNib(UINib(nibName: "CellWithConfimationButtons", bundle: nil), forCellWithReuseIdentifier: "incomingCell") self.collectionView.registerNib(UINib(nibName: "CellWithConfimationButtons", bundle: nil), forCellWithReuseIdentifier: "outgoingCell")
Now you can add your buttons to the xib files
Add Constraints so that it lays its self out right.
Set your Images for those and then you need to make your files that support this guy. Just like
JSQMessagesCollectionViewCellOutgoing.m
andJSQMessagesCollectionViewCellOutgoing.h
Then you need to add youIBOutlets
for the buttons and add the actions and logic in that fileThen you need to set a flag or some way of determining that the message is this type of message with buttons.
collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath)
you check for that flag and get your cell
if message.flag == true let cell = collectionView.dequeableCellWithIdentifier("incomingCell")
Then set everything up.
I hope that helps. let me know if I can help more.