Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Version 4
Home
/
Chat
/
JavaScript
/
Message

Mark messages as delivered

Copy link

Delivery receipt can be used to see whether a message has successfully been delivered to all the intended recipients by the Sendbird server. Call the markAsDelivered() method to mark a message as delivered for a group channel member who is online. For a member who is offline, markAsDelivered() should be called when the member brings the client app to the foregournd or comes back online.

Using a static method

Copy link
await sb.groupChannel.markAsDelivered(CHANNEL_URL);

Using an instance method

Copy link
const channel = await sb.groupChannel.getChannel(CHANNEL_URL);
await channel.markAsDelivered();

When a message is delivered to a group channel member who is online, the message is marked as delivered and other members who are online are notified of the delivery receipt through the onUndeliveredMemberStatusUpdated() method in the channel event handler.

const channelHandler = new GroupChannelHandler({
    onUndeliveredMemberStatusUpdated = (channel: GroupChannel) => {
        // ...
    },
});
sb.groupChannel.addGroupChannelHandler(UNIQUE_HANDLER_ID, channelHandler);