SendBird Threading not working

Two real issues I’m having here:

Issue #1

When sending a UserMessage and setting the parent message ID via the following

private fun sendTextMessage(text: String, parentId: ParentId?, type: String, callback:
    GMKMessageCallback?) {
        val params = UserMessageParams().apply {
            setMessage(text)
            setCustomType(type)
            parentId?.let {
                Timber.d("Setting text message parent id to $it")
                setParentMessageId(it)
            }
        }
        val tempMessage = getChannel().sendUserMessage(params) { message, error ->
            error?.let { Timber.w("$it") }
            callback?.invoke(message, error)
        }
        callback?.invoke(tempMessage, null)
    }

And from my view model:

private fun sendTextMessage(text: String, parentId: ParentId?) {
    messageService.sendTextMessage(text, parentId) { message, _ ->
        Timber.d("Send message with parent  ${message?.parentMessageId} ($parentId) - status ${message?.sendingStatus}")
        message?.let { _messageState.value = MessageState.Processed(it) }
    }
}

I receive the following log output:

2020-06-23 08:54:21.011 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService: Setting text message parent id to 5760282222
2020-06-23 08:54:21.015 12455-12455/gloo.phoenix.android.staging D/GroupChatViewModel$sendTextMessage: Send message with parent 5760282222 (5760282222) - status PENDING
2020-06-23 08:54:21.184 12455-12455/gloo.phoenix.android.staging D/GroupChatViewModel$sendTextMessage: Send message with parent 0 (5760282222) - status SUCCEEDED

As you can see, the parent message ID is set initially while the message is pending and, it seems, when successfully processed, the parent message ID is cleared.

Issue #2

The second issue deals with retrieving threaded messages for a parent message. Obviously, by looking at issue #1, we can probably guess that this won’t work, but here is my code and output.
I’m trying to load threaded messages via the following:

fun loadLatestComments(parentMessage: GMKBaseMessage, limit: Int, callback: GMKMessageQueryCallback?) {
    Timber.d("Loading latest comments for ${parentMessage.messageId}")
    val params = ThreadMessageListParams().apply {
        previousResultSize = limit
        isInclusive = true
        messageType = BaseChannel.MessageTypeFilter.ALL
        setReverse(false)
    }
    parentMessage.getThreadedMessagesByTimestamp(Long.MAX_VALUE, params, getThreadedMessageHandler(callback))
}

And my handler:

private fun getThreadedMessageHandler(callback: GMKMessageQueryCallback?) =
        BaseMessage.GetThreadedMessagesHandler { parent, replies, error ->
            error?.printStackTrace()
            Timber.d("Received ${replies?.size} replies from parent ${parent?.messageId}")
            replies?.forEach { Timber.d("Reply found with parent id: ${it.parentMessageId}") }
            callback?.invoke(replies, error)
        }

And here’s the logging output:

2020-06-23 08:59:47.890 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService: Loading latest comments for 5760282222
2020-06-23 08:59:48.085 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Received 11 replies from parent 5832347906
2020-06-23 08:59:48.086 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0
2020-06-23 08:59:48.090 12455-12455/gloo.phoenix.android.staging I/chatty: uid=10085(gloo.phoenix.android.staging) identical 9 lines
2020-06-23 08:59:48.090 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0
2020-06-23 08:59:48.207 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService: Loading previous comments for 5760282222
2020-06-23 08:59:48.314 12455-12514/gloo.phoenix.android.staging I/chatty: uid=10085(gloo.phoenix.android.staging) RenderThread identical 1 line
2020-06-23 08:59:48.377 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Received 11 replies from parent 5844605825
2020-06-23 08:59:48.377 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0
2020-06-23 08:59:48.380 12455-12455/gloo.phoenix.android.staging I/chatty: uid=10085(gloo.phoenix.android.staging) identical 9 lines
2020-06-23 08:59:48.381 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0
2020-06-23 09:00:01.375 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService: Loading previous comments for 5760282222
2020-06-23 09:00:01.561 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Received 8 replies from parent 5832125927
2020-06-23 09:00:01.562 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0
2020-06-23 09:00:01.566 12455-12455/gloo.phoenix.android.staging I/chatty: uid=10085(gloo.phoenix.android.staging) identical 6 lines
2020-06-23 09:00:01.566 12455-12455/gloo.phoenix.android.staging D/SendBirdMessageService$getThreadedMessageHandler: Reply found with parent id: 0

Note: I’m using paging which is why you see multiple loads

Four things I’m noticing here

  1. The correct parent message is being used to retrieve the threads (5760282222)
  2. For each load, the returned parent parameter has the wrong, and in each case, a different ID (5832347906, 5844605825, 5832125927, etc). But we can see that the call is Loading previous comments for 5760282222 which is using the correct parent ID.
  3. For each load, looping through the “replies,” we can see that the parentMessageId field is set to 0
  4. I also noticed, in my RecyclerView, that the original channel’s messages were being loaded in the thread call as well. Also, all comments made on other threads in that channel are being included. So it appears that the parent is being completely ignored when making this call.

I haven’t found examples on using the new threading calls for the SDK, but it seems like this should be working. Please let me know what I’m doing wrong if that is not the case. If this is a bug, I believe it is a pretty major bug as we now rely on using a workaround of setting the customType of each message to relate it to a specific parent.

Message Threading is not available yet. In the immediate term, you’ll have to rely on your own custom implementation.

I would suggest reaching out to your sales contact (if you have one), otherwise submit a Sales Inquiry request through your Sendbird Dashboard.

While I appreciate the work you all are doing, I would, respectfully, suggest not releasing features until they’re implemented. I was under the impression that, as of 3.0.130 (per the SDK reference), this had been added to enhance functionality. I wasted multiple hours on company time trying to figure out why nothing seemed to be working since all of the threading methods seemed to be functioning (no errors thrown and returning values where needed). I would, at the least, document that in the SDK reference and, if possible, throw an Exception when trying to use these features until they are implemented.

That brings up another question: what’s the quickest way know when the existing API is actually implemented so we can reintroduce the threading code into our app?

Apologies for the confusion. If functionality is released, it will be in the main online documentation (e.g. docs.sendbird.com/android).

New functionality may be enabled in the SDK prior to general availability and documented in the API reference. This is for customers who are in an early access program, or in preparation for general availability.

I do encourage you to reach out to sales, as they may be able to give you some guidance on availability for you.

Will do. And again, thanks for all the work you all are doing

We are a part of the EAP and this issue is occurring even with the feature turned on for our Sendbird instance