Package com.tomtom.ivi.platform.messaging.api.service.messagingprovider

The discoverable messaging provider service API package.

Messaging provider service

It is possible to extend the TomTom Digital Cockpit platform with new types of messaging. This is done by implementing a new discoverable MessagingProviderService. All available implementations will be discovered by the MessagingService and combined into a single view of all of messaging.

Overview of the messaging provider service

To create a new messaging provider, a class should be created that implements MessagingProviderServiceBase. Also, at least one message type should be defined.

class NewMessagingProvider(
iviServiceHostContext: IviServiceHostContext,
serviceIdProvider: IviDiscoverableServiceIdProvider
) : MessagingProviderServiceBase(iviServiceHostContext, serviceIdProvider) {
companion object {
private const val newMessageType = "com.tomtom.ivi.platform.messaging.api.common.model.type.EXAMPLE"

The easiest way to implement a messaging provider is to use the MessagingProviderHelper class.

    private val messagingProviderHelper = MessagingProviderHelper().also {
conversationsForProvider = it.conversations
messageTypesForProvider = it.messageTypes
it.registerSendMessageCallback { conversation, message ->
sendMessage(conversation, message)
it.setMessageTypeEnabled(newMessageType, true)

When a message is received, a conversation should be found or created for it, and the message should be added to the helper.

    fun onMessageReceived(contactName: String, contactPhoneNumber: String, contentText: String) {
val contact = MessagingContact(contactName, contactPhoneNumber, null)

val conversation = messagingProviderHelper.findOrCreateConversation(
contacts = setOf(contact),
messageType = newMessageType,
applicationDisplayName = "NewMessaging",

id =,
conversationId =,
author = contact,
contentText = contentText,
timestamp =,
state = MessageState.INCOMING_UNREAD

To send a message, an implementation for sendMessage should be provided.

private fun sendMessage(conversation: Conversation, message: Message): Boolean {
// Should send the specified [message].

Furthermore, some boilerplate code is necessary.

    override suspend fun replyUsingText(
conversationId: Uid<Conversation>,
contentText: String
): Boolean = messagingProviderHelper.addOrUpdateMessage(
id =,
conversationId = conversationId,
author = null,
state = MessageState.OUTGOING_QUEUED,
contentText = contentText,
timestamp =

override suspend fun getMessage(messageId: Uid<Message>): Message? =

override suspend fun markConversationReadUpToAndIncluding(
conversationId: Uid<Conversation>,
messageId: Uid<Message>
) {
messagingProviderHelper.markConversationReadUpToAndIncluding(conversationId, messageId)

override suspend fun updateMessageState(messageId: Uid<Message>, newState: MessageState) {
messagingProviderHelper.findMessageById(messageId)?.let {
messagingProviderHelper.addOrUpdateMessage(it.copy(state = newState))

override suspend fun getOrCreateConversationId(
conversationContacts: Set<ConversationContact>,
messageType: MessageType
): Uid<Conversation> {
require(messageType == newMessageType)
return messagingProviderHelper.findOrCreateConversation(


Link copied to clipboard
interface MessagingProviderService

A discoverable service that provides support for one or more types of messaging.