# NotificationCompat.MessagingStyle

# NotificationCompat.MessagingStyle

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.MessagingStyle)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/app/NotificationCompat.MessagingStyle "View this page in Java")

<br />

```
class NotificationCompat.MessagingStyle : NotificationCompat.Style
```

<br />

|---|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                                              |||
| ↳ | [androidx.core.app.NotificationCompat.Style](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style)                      ||
|   | ↳ | [androidx.core.app.NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) |

*** ** * ** ***

Helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people. In order to get a backwards compatible behavior, the app needs to use the v7 version of the notification builder together with this style, otherwise the user will see the normal notification view. Use[setConversationTitle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setConversationTitle(java.lang.CharSequence))to set a conversation title for group chats with more than two people. This could be the user-created name of the group or, if it doesn't have a specific name, a list of the participants in the conversation. Do not set a conversation title for one-on-one chats, since platforms use the existence of this field as a hint that the conversation is a group. This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so:  

```kotlin
Notification notification = new Notification.Builder()
    .setContentTitle("2 new messages with " + sender.toString())
    .setContentText(subject)
    .setSmallIcon(R.drawable.new_message)
    .setLargeIcon(aBitmap)
    .setStyle(new Notification.MessagingStyle(resources.getString(R.string.reply_name))
        .addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
        .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
    .build();
```

## Summary

|                                                                        ### Nested types                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message) |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MAXIMUM_RETAINED_MESSAGES](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#MAXIMUM_RETAINED_MESSAGES())` = 25` The maximum number of messages that will be retained in the Notification itself (the number displayed is up to the platform). |

|                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                       |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ~~[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#MessagingStyle(java.lang.CharSequence))~~`(userDisplayName: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` **This function is deprecated.** Use`#MessagingStyle(Person)`instead. <br />                                   |
| [MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#MessagingStyle(androidx.core.app.Person))`(user: `[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`)` Creates a new[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)object. |

|                                                                                                                                                                       ### Public functions                                                                                                                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                                     | [addCompatExtras](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addCompatExtras(android.os.Bundle))`(extras: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`)` This is called with the extras of the framework[Notification](https://developer.android.com/reference/android/app/Notification.html)during the[build](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#build())process, after`apply()`has been called.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | [addHistoricMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addHistoricMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message))`(message: `[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`?)` Adds a[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)for historic context in this notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | [addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message))`(message: `[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`?)` Adds a[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)for display in this notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | [addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(java.lang.CharSequence,long,androidx.core.app.Person))`(text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?, timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, person: `[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`?)` Adds a message for display by this notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | ~~[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(java.lang.CharSequence,long,java.lang.CharSequence))~~`(text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?, timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, sender: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?)` **This function is deprecated.** Use[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(java.lang.CharSequence,long,androidx.core.app.Person))or[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message)) <br />                                                                                                                                                                                                                    |
| `java-static `[NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)`?`                                                                                                                                                                                                          | [extractMessagingStyleFromNotification](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#extractMessagingStyleFromNotification(android.app.Notification))`(notification: `[Notification](https://developer.android.com/reference/android/app/Notification.html)`)` Retrieves a[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)from a[Notification](https://developer.android.com/reference/android/app/Notification.html), enabling an application that has set a[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)using[NotificationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat)or[Notification.Builder](https://developer.android.com/reference/android/app/Notification.Builder.html)to send messaging information to another application using[NotificationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat), regardless of the API level of the system. |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`                                                                                                                                                                                                                                                                 | [getConversationTitle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getConversationTitle())`()` Return the title to be displayed on this conversation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`!>` | [getHistoricMessages](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getHistoricMessages())`()` Gets the list of historic`Message`s in the notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`!>` | [getMessages](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getMessages())`()` Gets the list of`Message`objects that represent the notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)                                                                                                                                                                                                                                                                                 | [getUser](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUser())`()` Returns the person to be used for any replies sent by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`                                                                                                                                                                                                                                                                 | ~~[getUserDisplayName](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUserDisplayName())~~`()` **This function is deprecated.** Use[getUser](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUser())instead. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                                               | [isGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#isGroupConversation())`()` Returns`true`if this notification represents a group conversation, otherwise`false`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | [setConversationTitle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setConversationTitle(java.lang.CharSequence))`(conversationTitle: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?)` Sets the title to be displayed on this conversation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)                                                                                                                                                                                                                           | [setGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setGroupConversation(boolean))`(isGroupConversation: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Sets whether this conversation notification represents a group.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.core.app.NotificationCompat.Style](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style) |------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Notification](https://developer.android.com/reference/android/app/Notification.html)`?` | [build](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style#build())`()` If this Style object has been set on a notification builder, this method will build that notification and return it.                                                                                                                                      | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)            | [setBuilder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Style#setBuilder(androidx.core.app.NotificationCompat.Builder))`(builder: `[NotificationCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder)`?)` Link this rich notification style with a notification builder. | |

## Constants

### MAXIMUM_RETAINED_MESSAGES

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
const val MAXIMUM_RETAINED_MESSAGES = 25: Int
```

The maximum number of messages that will be retained in the Notification itself (the number displayed is up to the platform).  

## Public constructors

### MessagingStyle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#MessagingStyle(java.lang.CharSequence))(userDisplayName: CharSequence)
```
| **This function is deprecated.**   
|
Use`#MessagingStyle(Person)`instead.  

|                                                    Parameters                                                     |
|-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `userDisplayName: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html) | Required - the name to be displayed for any replies sent by the user before the posting app reposts the notification with those messages after they've been actually sent and in previous messages sent by the user added in[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message)) |

### MessagingStyle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
MessagingStyle(user: Person)
```

Creates a new[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)object. Note that[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)must have a non-empty name.  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `user: `[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person) | This[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)'s name will be shown when this app's notification is being replied to. It's used temporarily so the app has time to process the send request and repost the notification with updates to the conversation. |

## Public functions

### addCompatExtras

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun addCompatExtras(extras: Bundle): Unit
```

This is called with the extras of the framework[Notification](https://developer.android.com/reference/android/app/Notification.html)during the[build](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#build())process, after`apply()`has been called. This means that you only need to add data which won't be populated by the framework Notification which was built so far. Moreover, recovering builders and styles is only supported at API 19 and above, no implementation is required for current BigTextStyle, BigPictureStyle, or InboxStyle.  

### addHistoricMessage

Added in[1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)  

```
fun addHistoricMessage(message: NotificationCompat.MessagingStyle.Message?): NotificationCompat.MessagingStyle
```

Adds a[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)for historic context in this notification.

Messages should be added as historic if they are not the main subject of the notification but may give context to a conversation. The system may choose to present them only when relevant, e.g. when replying to a message through a[RemoteInput](https://developer.android.com/reference/kotlin/androidx/core/app/RemoteInput).

The messages should be added in chronologic order, i.e. the oldest first, the newest last.  

|                                                                              Parameters                                                                               |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `message: `[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`?` | The historic[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)to be added |

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this object for method chaining |

### addMessage

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun addMessage(message: NotificationCompat.MessagingStyle.Message?): NotificationCompat.MessagingStyle
```

Adds a[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)for display in this notification.  

|                                                                              Parameters                                                                               |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `message: `[NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)`?` | The[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)to be displayed |

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this object for method chaining |

### addMessage

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun addMessage(text: CharSequence?, timestamp: Long, person: Person?): NotificationCompat.MessagingStyle
```

Adds a message for display by this notification. Convenience call for[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message)).  

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|--------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this for method chaining |

|                                                                                      See also                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#Message(java.lang.CharSequence,long,androidx.core.app.Person)) |   |

### addMessage

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun [addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(java.lang.CharSequence,long,java.lang.CharSequence))(text: CharSequence?, timestamp: Long, sender: CharSequence?): NotificationCompat.MessagingStyle
```
| **This function is deprecated.**   
|
| Use[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(java.lang.CharSequence,long,androidx.core.app.Person))or[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message))

Adds a message for display by this notification. Convenience call for a simple[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)in[addMessage](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#addMessage(androidx.core.app.NotificationCompat.MessagingStyle.Message))  

|                                                 Parameters                                                  |
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`   | A[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html)to be displayed as the message content                                                                                                                                                                                                                                                                                                                                                                              |
| `timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                  | Time at which the message arrived in ms since Unix epoch                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `sender: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?` | A[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html)to be used for displaying the name of the sender. Should be`null`for messages by the current user, in which case the platform will insert[getUserDisplayName](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUserDisplayName()). Should be unique amongst all individuals in the conversation, and should be consistent during re-posts of the notification. |

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this object for method chaining |

|                                                                                     See also                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#Message(java.lang.CharSequence,long,java.lang.CharSequence)) |   |

### extractMessagingStyleFromNotification

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun extractMessagingStyleFromNotification(notification: Notification): NotificationCompat.MessagingStyle?
```

Retrieves a[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)from a[Notification](https://developer.android.com/reference/android/app/Notification.html), enabling an application that has set a[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)using[NotificationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat)or[Notification.Builder](https://developer.android.com/reference/android/app/Notification.Builder.html)to send messaging information to another application using[NotificationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat), regardless of the API level of the system.  

|                                                                  Returns                                                                   |
|--------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)`?` | `null`if there is no[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)set, or if the SDK version is \<`16`(JellyBean). |

### getConversationTitle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getConversationTitle(): CharSequence?
```

Return the title to be displayed on this conversation. Can be`null`.  

### getHistoricMessages

Added in[1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)  

```
fun getHistoricMessages(): (Mutable)List<NotificationCompat.MessagingStyle.Message!>
```

Gets the list of historic`Message`s in the notification.  

### getMessages

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getMessages(): (Mutable)List<NotificationCompat.MessagingStyle.Message!>
```

Gets the list of`Message`objects that represent the notification.  

### getUser

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getUser(): Person
```

Returns the person to be used for any replies sent by the user.  

### getUserDisplayName

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun [getUserDisplayName](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUserDisplayName())(): CharSequence?
```
| **This function is deprecated.**   
|
| Use[getUser](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUser())instead.

Returns the name to be displayed for any replies sent by the user.  

### isGroupConversation

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun isGroupConversation(): Boolean
```

Returns`true`if this notification represents a group conversation, otherwise`false`.

If the application that generated this[MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle)targets an SDK version less than[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P())and[setGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setGroupConversation(boolean))was not called, this method becomes dependent on whether or not the conversation title is set; returning`true`if the conversation title is a non-null value, or`false`otherwise. This is to maintain backwards compatibility. Regardless,[setGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setGroupConversation(boolean))has precedence over this legacy behavior. From[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P())forward,[setConversationTitle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setConversationTitle(java.lang.CharSequence))has no affect on group conversation status.  

|                                                                                See also                                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setConversationTitle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setConversationTitle(java.lang.CharSequence)) |   |

### setConversationTitle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun setConversationTitle(conversationTitle: CharSequence?): NotificationCompat.MessagingStyle
```

Sets the title to be displayed on this conversation. May be set to`null`.

This API's behavior was changed in SDK version[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P()). If your application's target version is less than[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P()), setting a conversation title to a non-null value will make[isGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#isGroupConversation())return`true`and passing`null`will make it return`false`. This behavior can be overridden by calling[setGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#setGroupConversation(boolean))regardless of SDK version. In[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P())and above, this method does not affect group conversation settings.  

|                                                       Parameters                                                       |
|------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| `conversationTitle: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?` | Title displayed for this conversation |

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this object for method chaining |

### setGroupConversation

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun setGroupConversation(isGroupConversation: Boolean): NotificationCompat.MessagingStyle
```

Sets whether this conversation notification represents a group. An app should set isGroupConversation`true`to mark that the conversation involves multiple people.

Group conversation notifications may display additional group-related context not present in non-group notifications.  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| `isGroupConversation: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the conversation represents a group,`false`otherwise. |

|                                                                 Returns                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle) | this object for method chaining |

|                                                                    See also                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [isGroupConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#isGroupConversation()) |   |