Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messageInputBar.delegate = self does not work #33

Open
taigaisatiger opened this issue Feb 1, 2021 · 0 comments
Open

messageInputBar.delegate = self does not work #33

taigaisatiger opened this issue Feb 1, 2021 · 0 comments

Comments

@taigaisatiger
Copy link

I am trying to trying to implement a chat feature in my app but it is not going so well.
I was trying to check if the send button was working correctly by printing out "button is pushed", but it didn't get printed.
I realized messageInputBar.delegate = self was not in the code and I thought that was the problem and as I put in the line of code an error below popped up. I don't know how to fix this and it would be a great help if you could give me an advice on what I should do.
Cannot assign value of type 'MessageKitChatViewController' to type 'InputBarAccessoryViewDelegate?' Add missing conformance to 'InputBarAccessoryViewDelegate' to class 'MessageKitChatViewController'

`import UIKit
import MessageKit
import MessageInputBar
import FirebaseFirestore
import FirebaseAuth
import FirebaseStorage
import Nuke

struct Sender: SenderType{
var senderId: String
var displayName: String
}

struct MessageKitMessage: MessageType{
var sender: SenderType
var messageId: String
var sentDate: Date
var kind: MessageKind
}

class MessageKitChatViewController: MessagesViewController, MessagesDataSource, MessagesLayoutDelegate, MessagesDisplayDelegate, MessageInputBarDelegate{

var senderUser = Auth.auth().currentUser!
var messages = [MessageType]()

let currentUser = Sender(senderId: Auth.auth().currentUser!.uid , displayName: Auth.auth().currentUser!.displayName ??  "Name not found")



override func viewDidLoad() {
    super.viewDidLoad()
    messagesCollectionView.messagesDataSource = self
    messagesCollectionView.messagesLayoutDelegate = self
    messagesCollectionView.messagesDisplayDelegate = self
    messageInputBar.delegate = self
}

func currentSender() -> SenderType {
    return currentUser
}

func messageForItem(at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageType {
    return messages[indexPath.section]
}

func numberOfSections(in messagesCollectionView: MessagesCollectionView) -> Int {
    return messages.count
}


func messageInputBar(_ inputBar: MessageInputBar, didPressSendButtonWith text: String) {

// let message = MessageKitMessage(sender: currentUser, messageId: UUID().uuidString, sentDate: Timestamp().dateValue(), kind: .text(text))
print("button is pushed")
}

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant