Messagekit: Text with emoticons split on the example app

Created on 5 Mar 2018  路  9Comments  路  Source: MessageKit/MessageKit

General Information

  • MessageKit Version:

  • iOS Version(s):

  • Swift Version:

  • Devices/Simulators: iPhone X

  • Reproducible in ChatExample? (Yes/No): Yes

What happened? When i send a message which contains text and emoticons it splits up the message in multiple parts. How do we go about to solve it.

What did you expect to happen?

The message including emoticons should be considered as 1 single message and shouldn't automatically split.

confirmed bug

All 9 comments

Looks related to #541. I'm confused why this is happening? This can't be a MessageKit problem. Please share your code for the MessageType creation.

Thanks for the fast reply. I've simply used the default Example that came along with the library and when I use a text with emoticon For eg. "Hello EMOTICON Peter" it breaks the text in 3 parts "Hello", "EMOTICON", "Peter". I am not able to use emoticons in a single text message. So, I was wondering if the library allows it or not ? Thanks again. Its a great effort by you guys anyways. :)

I think you are incorrectly using the InputTextView.components property. What is your code for when the send button is tapped

Hi @ankitpolaris ,

I have used below code and working properly for text with emojies: -

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

    let attributedText = NSAttributedString(string: text, attributes: [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.blue])

    let message = MockMessage(attributedText: attributedText, sender: currentSender(), messageId: UUID().uuidString, date: Date())
    messageList.append(message)
    messagesCollectionView.insertSections([messageList.count - 1])

    inputBar.inputTextView.text = String()
    messagesCollectionView.scrollToBottom()
}

Hello, Thanks a lot for the update. The above code solved my concern :)

Hi, I have the similar problem. The hybrid multilingual message is splitted into separate parts. For example,
the single message "浣犲ソJane" is separated two messages: "浣犲ソ" and "Jane".

@ankitpolaris Sorry to have sent you in the wrong direction in this one. It took the same thing happening with Chinese characters to realize that it was indeed a bug in MessageKit. This has been resolved in #577

why we were using InputTextView.components?
Why we were using the single component as text?
I think emojis treated as another component that's why message split into two parts.
I have resolved my bug to remove this loop for components

for component in inputBar.inputTextView.components {}

and simply use inputBar.inputTextView.text

components separates strings and images. If you aren't allowing image paste it's not needed.

Sent with GitHawk

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlequeux picture mlequeux  路  3Comments

omaralbeik picture omaralbeik  路  4Comments

JulienLevallois picture JulienLevallois  路  4Comments

Abacaxi-Nelson picture Abacaxi-Nelson  路  4Comments

TheDarkCode picture TheDarkCode  路  3Comments