> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sound Manager

> The incoming-message sound in the CometChat iOS UI Kit v6 — CometChatSoundManager, and turning the sound off or replacing it per component in SwiftUI and UIKit.

> [accordion] AI Integration Quick Reference
>
> ```json theme={null}
> {
>   "type": "CometChatSoundManager (CometChatCore)",
>   "play": "CometChatSoundManager.shared.playIncomingMessage(custom: URL?) — nil plays the system tick",
>   "components": {
>     "swiftUI": "CometChatConversations / CometChatMessageList (disableSoundForMessages:, customSoundForMessages:)",
>     "uiKit": "conversations.disableSoundForMessages, set(customSoundForMessages:); messageList.disableSoundForMessages, set(customSoundForMessages:)"
>   },
>   "rule": "disableSoundForMessages wins over customSoundForMessages",
>   "notInV6": ["incoming/outgoing call sounds", "outgoing message sound", "pause / pauseSilently / release"],
>   "related": ["/ui-kit/ios/v6/localize"]
> }
> ```

`CometChatSoundManager` plays the Kit's incoming-message sound. It lives in `CometChatCore`
and is shared by both toolkits.

It plays through `AudioServices`, not `AVAudioPlayer`: a short UI sound needs no
`AVAudioSession`, so the Kit never changes your app's audio session, ducks the user's music or
interrupts a call.

***

## Sound Events

| Sound | When it plays |
| - | - |
| Incoming message | a message arrives — in Conversations for any chat, in the message list for the open chat when it lands at the latest position from another user |

> [!NOTE]
>
> The iOS v6 Kit plays only the incoming-message sound. The UIKit outgoing-call screen has a
> `set(customSoundForCalls:)` setter, but it plays nothing.

***

## Usage

The API is the same in both toolkits, because `CometChatSoundManager` is in `CometChatCore`.

> [tab] SwiftUI
>
> ```swift theme={null}
> // The system "received message" sound.
> CometChatSoundManager.shared.playIncomingMessage()
>
> // A sound file in your app bundle.
> if let url = Bundle.main.url(forResource: "ping", withExtension: "caf") {
>     CometChatSoundManager.shared.playIncomingMessage(custom: url)
> }
> ```

> [tab] UIKit
>
> ```swift theme={null}
> // The system "received message" sound.
> CometChatSoundManager.shared.playIncomingMessage()
>
> // A sound file in your app bundle.
> if let url = Bundle.main.url(forResource: "ping", withExtension: "caf") {
>     CometChatSoundManager.shared.playIncomingMessage(custom: url)
> }
> ```

A custom file is registered once and cached, so playing it again is cheap. Use a short file
that `AudioServices` can play — `.caf`, `.aif` or `.wav`, under 30 seconds.

***

## Disable or Replace Sounds on Components

`disableSoundForMessages` wins over `customSoundForMessages`.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(disableSoundForMessages: true)
>
> CometChatMessageList(
>     user: user,
>     customSoundForMessages: Bundle.main.url(forResource: "ping", withExtension: "caf")
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations.disableSoundForMessages = true
>
> if let url = Bundle.main.url(forResource: "ping", withExtension: "caf") {
>     messageList.set(customSoundForMessages: url)
> }
> ```

### Choose which messages sound

The message list asks its policy before playing. Return `false` to stay silent for a message:

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatMessageList(
>     user: user,
>     policy: MessageListPolicy(shouldPlaySound: { message in message.kind == .text })
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> messageList.store.policy = MessageListPolicy(shouldPlaySound: { message in message.kind == .text })
> ```

***

## API Reference

| Member | Description |
| - | - |
| `CometChatSoundManager.shared` | the shared instance the Kit uses |
| `init()` | a separate instance, with its own cache |
| `playIncomingMessage(custom:)` | plays `custom`, or the system "received message" sound when `nil` |

## Next Steps

> [card] [Localize](https://www.cometchat.com/docs/ui-kit/ios/v6/localize.md)
>
> Languages and date formats.

> [card] [Customization Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-overview.md)
>
> Every way to change the Kit.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.