I’m using UIKit version 2.1.4 and I’m having a bit of an issue trying to display my own custom cell for a custom message type.
From my understanding reading the docs, if I call the register(customMessageCell:) function, then any message sent to the chat with a customType should be displayed using my custom cell. But in practice my custom cell is being ignored, and custom messages are still being displayed as a regular user message.
I’ve attached some sample code below. Is this a bug in the UIKit SDK? Or is it possible that I’ve missed a step?
The customMessageCell is used for you to add additional custom message cell, apart from our default userMessageCell, fileMessageCell, adminMessageCell and unknownMessageCell.
Once the customMessageCell is registered by register(customMessageCell:, nib:), it’s registered with cellReuseIdentifier
as customMessageCell.sbu_className, so you’ll need to retrieve the cell from tableView(_ tableView:, cellForRowAt indexPath:) using the same identifier, and configure your custom cell.
If you wish to register it with other reuseIdentifier, you can do it so by registering it directly using the tableView property.
We’ll fix the docs as this customMessageCell has nothing to do with the message’s custom type.
I did a bit more digging and I actually stumbled across a much easier way to implement custom cells, by overriding the generateCellIdentifier(by message:) function in SBUChannelViewController. I can’t find a reference to this function anywhere in the documentation but it does exactly what I need.
Here’s an updated example of my code in case anyone is trying to achieve the same thing as me: