> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-angular-v5-docs-update.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Groups With Messages

> Groups With Messages — CometChat documentation.

## Overview

`GroupsWithMessages` is a [Composite Component](/ui-kit/ios/v4/components-overview#composite-components) encapsulating functionalities from the [Groups](/ui-kit/ios/v4/groups) and [Messages](/ui-kit/ios/v4/messages) components. Serving as a versatile wrapper, it seamlessly integrates with CometChatMessages, enabling users to open the module by clicking on any group within the list. This component inherits the behavior of Groups, fostering consistency and familiarity in user interactions.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-angular-v5-docs-update/xHWe3as1OGB4Vmrv/images/8fdd1f93-gwm_overview_screens-bcc59e6c4a99d9657e735b7d07feb71e.png?fit=max&auto=format&n=xHWe3as1OGB4Vmrv&q=85&s=2b885e767b8f4c03e61ecc503b1b8d07" width="2653" height="3120" data-path="images/8fdd1f93-gwm_overview_screens-bcc59e6c4a99d9657e735b7d07feb71e.png" />
</Frame>

| Components                          | Description                                                                                                                    |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [Groups](/ui-kit/ios/v4/groups)     | The `Groups` component is designed to display a list of `Groups`. This essentially represents the recent conversation history. |
| [Messages](/ui-kit/ios/v4/messages) | The `Messages` component is designed to manage the messaging interaction for `Group's` conversations.                          |

## Usage

### Integration

As `GroupsWithMessages` is a **view controller**, it can be effortlessly added directly in response to a button click or any event. Leveraging all the customizable properties and methods inherited from Groups, this component offers seamless integration and extensive customization capabilities. This makes it a versatile solution for enhancing user interaction within your application.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
    let naviVC = UINavigationController(rootViewController: cometChatGroupsWithMessages)
    self.present(naviVC, animated: true)
    ```
  </Tab>
</Tabs>

<Note>
  If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
</Note>

***

### Actions

[Actions](/ui-kit/ios/v4/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. SetOnItemClick

This method proves valuable when users seek to override onItemClick functionality within GroupsWithMessages, empowering them with greater control and customization options.

The `setOnItemClick` action doesn't have a predefined behavior. You can override this action using the following code snippet.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
    .setOnItemClick (onItemClick:{ group, indexPath in
    //Perform Your Action
    })
    ```
  </Tab>
</Tabs>

##### 2. SetOnItemLongClick

This method becomes invaluable when users seek to override long-click functionality within GroupsWithMessages, offering them enhanced control and flexibility in their interactions.

The `setOnItemLongClick` action doesn't have a predefined behavior. You can override this action using the following code snippet.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
    .setOnItemLongClick (onItemLongClick:{ group, indexPath in
    //Perform Your Action

    })
    ```
  </Tab>
</Tabs>

##### 3. SetOnError

You can customize this behavior by using the provided code snippet to override the `On Error` and improve error handling.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .setOnError (onError:{ error in
        //Perform Your Action

    })
    ```
  </Tab>
</Tabs>

##### 4. SetOnBack

Enhance your application's functionality by leveraging the `SetOnBack` feature. This capability allows you to customize the behavior associated with navigating back within your app. Utilize the provided code snippet to override default behaviors and tailor the user experience according to your specific requirements.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .setOnBack (onBack:{
        //Perform Your Action

    })
    ```
  </Tab>
</Tabs>

### Filters

**Filters** allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

While the GroupsWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to [Groups Filters](/ui-kit/ios/v4/groups#filters) and [Messages Filters](/ui-kit/ios/v4/messages#filters).

By utilizing the [Configurations](#configurations) object of its components, you can apply filters.

In the following **example**, we are applying a filter to the Group List based on only joined groups and setting the limit to 3 using the `groupsRequestBuilder`.

<Tabs>
  <Tab title="Swift">
    ```swift Swift theme={null}
      // You can create GroupRequestBuilder as per your requirement
    let groupsRequestBuilder = GroupsRequest.GroupsRequestBuilder(limit: 3).set(joinedOnly: true)

    let groupsWithMessages = CometChatGroupsWithMessages(groupsRequestBuilder: groupsRequestBuilder)

    let naviVC = UINavigationController(rootViewController: groupsWithMessages)
    self.present(naviVC, animated: true)
    ```
  </Tab>
</Tabs>

<Note>
  If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
</Note>

***

### Events

[Events](/ui-kit/ios/v4/components-overview#events) are emitted by a `Component`. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The GroupsWithMessages does not produce any events but its component does.

***

## Customization

To fit your app's design requirements, you have the ability to customize the appearance of the GroupsWithMessages component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

### Style

Using **Style** you can **customize** the look and feel of the component in your app, These parameters typically control elements such as the **color**, **size**, **shape**, and **fonts** used within the component.

##### 1. GroupsWithMessages Style 🛑

You can set the `groupsWithMessagesStyle` to the GroupsWithMessages Component to customize the styling.

<Tabs>
  <Tab title="Swift">
    ```swift Swift theme={null}
    let groupsWithMessagesStyle = GroupsWithMessageStyle()
        .set(background: .init(red: 0.65, green: 0.53, blue: 0.89, alpha: 1.00))
        .set(borderColor: .systemPurple)
        .set(messageTextFont: .boldSystemFont(ofSize: 11))

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()

    let naviVC = UINavigationController(rootViewController: cometChatGroupsWithMessages)
    self.present(naviVC, animated: true)
    ```
  </Tab>
</Tabs>

<Note>
  If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
</Note>

You can also customize its component styles. For more details on individual component styles, you can refer [Groups Styles](/ui-kit/ios/v4/groups#style) and [Messages Styles](/ui-kit/ios/v4/messages#messagesstyle).

Styles can be applied to SubComponents using their respective [configurations](#configurations).

***

### Functionality

These are a set of **small functional customizations** that allow you to **fine-tune** the overall experience of the component. With these, you can **change text**, set **custom icons**, and toggle the **visibility** of UI elements.

The GroupsWithMessages component currently does not offer any available functionality.

##### Components

Nearly all functionality customizations available for a Component are also available for the composite component. Using [Configuration](#configurations), you can modify the properties of its components to suit your needs.

You can find the list of all Functionality customization of individual components in [Groups](/ui-kit/ios/v4/groups#functionality) and [Messages](/ui-kit/ios/v4/messages#functionality).

**Example**

<Tabs>
  <Tab title="Swift">
    ```swift Swift theme={null}
    let messagesConfiguration = MessagesConfiguration()
        .disable(disableTyping: true)
        .hide(messageHeader: true)

    let groupsConfiguration = GroupsConfiguration()
        .hide(search: true)

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(messagesConfiguration: messagesConfiguration)
        .set(groupsConfiguration: groupsConfiguration)
    ```
  </Tab>
</Tabs>

<Note>
  Ensure to pass and present `cometChatGroupsWithMessages`. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.
</Note>

***

### Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your own views, layouts, and UI elements and then incorporate those into the component.

By utilizing the [Configuration](#configurations) object of each component, you can apply advanced-level customizations to the GroupsWithMessages.

**Example**

```swift theme={null}
// Create an object of  GroupsConfiguration
let groupsConfiguration = GroupsConfiguration()
.set(errorStateView: UIView)
```

**Usage**

You can utilize the groupsConfiguration object within a CometChatGroupsWithMessages widget. Simply set the groupsConfiguration using the `.set(groupsConfiguration: groupsConfiguration)` method when initializing the `CometChatGroupsWithMessages` instance.

```swift theme={null}
let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
.set(groupsConfiguration: groupsConfiguration)
```

To find all the details on individual Component advance customization you can refer, [Groups Advance](/ui-kit/ios/v4/groups#advanced) and [Messages Advance](/ui-kit/ios/v4/messages#advanced).

GroupsWithMessages uses advanced-level customization of both Groups & Messages components to achieve its default behavior.

1. GroupsWithMessages utilizes the [SetMenu](/ui-kit/ios/v4/groups#setmenu) function of the `Groups` subcomponent to navigate the user from [Groups](/ui-kit/ios/v4/groups) to [Messages](/ui-kit/ios/v4/messages)

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-angular-v5-docs-update/6IESCr-kzBV6qAKP/images/84ef2511-gwm_advanc_1_screens-c8c51a5a3a0d1b889f5666cbc7d4ec6f.png?fit=max&auto=format&n=6IESCr-kzBV6qAKP&q=85&s=2ec9053c02ad878dc6c81da03cc3b191" width="4948" height="3120" data-path="images/84ef2511-gwm_advanc_1_screens-c8c51a5a3a0d1b889f5666cbc7d4ec6f.png" />
</Frame>

2. GroupsWithMessages utilizes the [SetMenu](/ui-kit/ios/v4/messages#setmenu) function of the `Messages` subcomponent to navigate the user from [Messages](/ui-kit/ios/v4/messages) to [Details](/ui-kit/ios/v4/user-details).

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-angular-v5-docs-update/1AfY8AvJMqtx4lQu/images/27eae06e-gwm_advance_2_screens-37f2750862e366bbc3a9bab2133dc375.png?fit=max&auto=format&n=1AfY8AvJMqtx4lQu&q=85&s=dce79cfbd8a63f0b191d828f58dc6880" width="4948" height="3120" data-path="images/27eae06e-gwm_advance_2_screens-37f2750862e366bbc3a9bab2133dc375.png" />
</Frame>

<Warning>
  When you override `.setMenu()`, the default behavior of GroupsWithMessages will also be overridden.
</Warning>

## Configurations

[Configurations](/ui-kit/ios/v4/components-overview#configurations) offer the ability to customize the properties of each component within a Composite Component.

GroupsWithMessages has `Groups` and `Messages` component. Hence, each of these components will have its individual \`Configuration\`\`.

* `Configurations` expose properties that are available in its individual components.

#### Groups

You can customize the properties of the Groups component by making use of the `groupsConfiguration`. You can accomplish this by employing the `groupsConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let groupsConfiguration = GroupsConfiguration()
        // Customize properties of groups by overriding them.

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(groupsConfiguration: groupsConfiguration)
    ```
  </Tab>
</Tabs>

All exposed properties of `GroupsConfiguration` can be found under [Groups](/ui-kit/ios/v4/groups#configuration). Properties marked with the <Tooltip tip="Not available">🛑</Tooltip> symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Groups subcomponent and, in addition, you only want to display the Group List based on only joined groups and setting the limit to 3.

You can modify the style using the `groupsStyle` property and filter the list with the `groupsRequestBuilder` property.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let groupsStyle = GroupsStyle()
        .set(background: .init(red: 0.72, green: 0.45, blue: 0.95, alpha: 1.00))
        .set(backIconTint: .black)
        .set(largeTitleColor: .cyan)

    let groupsConfiguration = GroupsConfiguration()
        .set(style: groupsStyle)

    let groupsRequestBuilder = GroupsRequest.GroupsRequestBuilder(limit: 3).set(joinedOnly: true)

    let groupsWithMessages = CometChatGroupsWithMessages(groupsRequestBuilder: groupsRequestBuilder)
        .set(groupsConfiguration: groupsConfiguration)
    ```
  </Tab>
</Tabs>

***

#### Messages

You can customize the properties of the Messages component by making use of the messagesConfiguration. You can accomplish this by employing the `messagesConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let  messagesConfiguration = MessagesConfiguration()
        // Customize properties by overriding them.

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(messagesConfiguration: messagesConfiguration)
    ```
  </Tab>
</Tabs>

All exposed properties of `MessagesConfiguration` can be found under [Messages](/ui-kit/ios/v4/messages#configuration). Properties marked with the <Tooltip tip="Not available">🛑</Tooltip> symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Messages subcomponent and, in addition, you only want to hide message header.

You can modify the style using the `messagesStyle` property and hide the message header with the `hideMessageHeader` property.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let messagesStyle = MessagesStyle()
        .set(background: .init(red: 0.72, green: 0.45, blue: 0.95, alpha: 1.00))
        .set(borderColor: .systemPink)
        .set(borderWidth: 3)

    let messagesConfiguration = MessagesConfiguration()
        .set(messagesStyle: messagesStyle)
        .hide(messageHeader: true)

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(messagesConfiguration: messagesConfiguration)
    ```
  </Tab>
</Tabs>

<Note>
  Ensure to pass and present `cometChatGroupsWithMessages`. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.
</Note>

***

#### Join Group

You can customize the properties of the Join Group component by making use of the JoinGroupConfiguration. You can accomplish this by employing the `joinGroupConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let joinProtectedGroupConfiguration = JoinProtectedGroupConfiguration()
        // Customize properties by overriding them.

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(joinProtectedGroupConfiguration: joinProtectedGroupConfiguration)
    ```
  </Tab>
</Tabs>

All exposed properties of `JoinGroupConfiguration` can be found under [Join Group](/ui-kit/ios/v4/join-protected-group#configurations). Properties marked with the <Tooltip tip="Not available">🛑</Tooltip> symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Join Group subcomponent.

You can modify the style using the `joinGroupStyle` property.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let joinProtectedGroupStyle = JoinProtectedGroupStyle()
        .set(background: .init(red: 0.72, green: 0.45, blue: 0.95, alpha: 1.00))
        .set(joinButtonTextColor: .orange)
        .set(passwordTextColor: .systemTeal)

    let joinProtectedGroupConfiguration = JoinProtectedGroupConfiguration()
        .set(joinProtectedGroupStyle: joinProtectedGroupStyle)
        // Customize properties by overriding them.

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(joinProtectedGroupConfiguration: joinProtectedGroupConfiguration)
    ```
  </Tab>
</Tabs>

<Note>
  Ensure to pass and present `cometChatGroupsWithMessages`. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.
</Note>

***

#### Create Group

You can customize the properties of the Create Group component by making use of the CreateGroupConfiguration. You can accomplish this by employing the `createGroupConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let createGroupConfiguration = CreateGroupConfiguration()
        .set(createGroupStyle: createGroupStyle)
        // Customize properties by overriding them.

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(createGroupConfiguration: createGroupConfiguration)
    ```
  </Tab>
</Tabs>

All exposed properties of `CreateGroupConfiguration` can be found under [Create Group](/ui-kit/ios/v4/create-group#configurations). Properties marked with the <Tooltip tip="Not available">🛑</Tooltip> symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Create Group subcomponent.

You can modify the style using the `createGroupStyle` property.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let createGroupStyle = CreateGroupStyle()
        .set(background: .init(red: 0.72, green: 0.45, blue: 0.95, alpha: 1.00))
        .set(titleTextColor: .systemCyan)
        .set(borderColor: .systemPurple)

    let createGroupConfiguration = CreateGroupConfiguration()
        .set(createGroupStyle: createGroupStyle)

    let cometChatGroupsWithMessages = CometChatGroupsWithMessages()
        .set(createGroupConfiguration: createGroupConfiguration)
    ```
  </Tab>
</Tabs>

<Note>
  Ensure to pass and present `cometChatGroupsWithMessages`. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.
</Note>

***
