/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Mark messages as delivered

Copy link

Delivery receipt can be used to see whether a message has been successfully delivered to all the intended recipients by the Sendbird server. Using the SendbirdChat.markAsDelivered() method, you can mark a message as delivered when an offline group channel member receives a push notification through Firebase Cloud Messaging. However, to ensure proper functionality, the SendbirdChat.init() method must be called within the Application.onCreate() method; otherwise, the markAsDelivered() method may not work as intended for push notifications received when the app is in a terminated state.

class FirebaseMessagingServiceEx : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage: RemoteMessage) {

        // SendbirdChat.init() must be called prior to this call.
        SendbirdChat.markAsDelivered(remoteMessage.data)
    }
}

Receive callbacks for delivery receipts

Copy link

When a message is delivered to group channel members who are online, it is automatically marked as delivered and channel members are also notified of the message delivery through the onDeliveryStatusUpdated() method in the channel event handler.

SendbirdChat.addChannelHandler(
    UNIQUE_HANDLER_ID,
    object : GroupChannelHandler() {
        override fun onMessageReceived(channel: BaseChannel, message: BaseMessage) {
            // ...
        }

        override fun onDeliveryStatusUpdated(channel: GroupChannel) {
            // ...
        }
    }
)