Is it possible to cancel/delete a pending text message?

[Problem/Question]
Is it possible to cancel/delete a pending text message?

When there is no internet connection, a message will be in SendingStatus.PENDING state. However, calling channel.deleteMessage(message, handler) will return an error exception saying there’s no internet connection. Just wondering is there a way to cancel or delete this pending message while offline? I’m not even sure if deleteMessage works for pending messages while there is internet, as it moves from PENDING to SUCCEEDED too quickly before I can try it.

Going through the Android SDK documentation, seems like we can cancel a pending FileMessage using channel.cancelFileMessageUpload(fileMessage.requestId), but there’s nothing like channel.cancelMessage() ?

The reason we need this is, the user could have a bad internet connection for several hours, and the message they meant to send earlier might not be relevant anymore, but they have no choice but to send it as soon as internet connection is back online. We want to allow the user to delete any messages that has not been sent yet. As for why we could not use deleteMessage after it is sent, that’s because our app needs to retain the chat history and we disallow user from deleting or editing a message after they have been sent successfully, hope that makes sense.

Thanks,
Bruce

Hi I have this problem too, but with messages that failed to be sent. Did you find a solution to this?

After asking the support team, I was told that the way to delete not yet sent messages (either in error or pending) is to call deleteMessage() on BaseMessageListFragment, which is unfortunately protected. The way to do this is to extend ChannellFragment exposing the method:

class CustomChannelFragment : ChannelFragment() {
   fun deleteEvenLocalMessage(message: BaseMessage) {
        //this is protected so it needs to be exposed.
        super.deleteMessage(message)
    }
}

and using your version when building the ChannelFragment:

channelFragment = ChannelFragment.Builder(channel.url)
                .setCustomFragment(CustomChatChannelFragment())
                .build()

hopefully it gets documented or improved in the future