Reputation: 3393
I am trying to use MessageKit inside my application, and I have the view loading and showing messages.
However, the "Send" button never triggers the messageInputBar delegate and I am unsure why. There is not much to hook up, if I downgrade to version 1.0.0, it works and triggers when you press Send, upgrade to the newest version and it breaks.
import UIKit
import MessageKit
import InputBarAccessoryView
private var messages: [Message] = []
class InboxThreadViewController: MessagesViewController, MessageInputBarDelegate {
@objc public var myValue:String?
private var messages: [Message] = []
override func viewDidLoad() {
super.viewDidLoad()
messageInputBar.delegate = self
messagesCollectionView.messagesDataSource = self
messagesCollectionView.messagesLayoutDelegate = self
messagesCollectionView.messagesDisplayDelegate = self
title = "MessageKit"
func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) {
print("Message : \(text)")
NSLog("HELLO")
}
}
Upvotes: 0
Views: 1255
Reputation: 97
my MessageKit (3.0.0) is working,
before:
func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String)
after:
func inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String)
Upvotes: 1
Reputation: 2760
To resolve this problem you have to extend instead of MessageInputBarDelegate the InputBarAccessoryViewDelegate protocol. To make your code more elegant, proceed this way :
class InboxThreadViewController: MessagesViewController { .. }
extension InboxThreadViewController: InputBarAccessoryViewDelegate {
func inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String) {
//Handle message input text here
}
}
Upvotes: 1