Skip to main content
FieldValue
GoalManage audio playback for incoming/outgoing calls and messages
Importimport { CometChatSoundManager } from "@cometchat/chat-uikit-react-native";
Play soundCometChatSoundManager.play("incomingMessage")
Custom soundCometChatSoundManager.play("outgoingMessage", "path/to/sound.mp3")
Pause soundCometChatSoundManager.pause()
Sound eventsincomingMessage, incomingMessageFromOther, outgoingMessage, incomingCall, outgoingCall
Default behaviorPlays built-in sounds; pass custom path as second arg to override
CometChatSoundManager is a helper class for managing and playing audio cues in the UI Kit — incoming/outgoing calls and messages.

Sound Events

Event KeyWhen It Plays
incomingMessageNew message received from current conversation
incomingMessageFromOtherNew message received from a different conversation
outgoingMessageMessage sent
incomingCallIncoming call detected (loops)
outgoingCallOutgoing call initiated (loops)

Methods

play

Plays the default or custom audio resource for a given sound event.
ParameterTypeDescription
soundstringSound event key: "incomingMessage", "outgoingMessage", "incomingCall", "outgoingCall"
customSoundstringOptional custom audio file path. Defaults to built-in sound.
isRequirebooleanOptional. Set to true if using require() for local assets.
import { CometChatSoundManager } from "@cometchat/chat-uikit-react-native";

// Play default sound
CometChatSoundManager.play("incomingMessage");

// Play custom sound
CometChatSoundManager.play("outgoingMessage", "path/to/custom-sound.mp3");

pause

Pauses the currently playing sound and resets playback position.
CometChatSoundManager.pause();

Usage

Here is how to use CometChatSoundManager:
// Play sound with default sound:
CometChatSoundManager.play("incomingMessage"); // To play default incoming message sound
CometChatSoundManager.play("outgoingMessage"); // To play default outgoing message sound

// Play sound with custom sound
CometChatSoundManager.play("outgoingMessage", "assetPath"); // To play custom message sound

// Pause Sound:
CometChatSoundManager.pause();
By using the CometChatSoundManager, you can enhance the user experience in your chat application by integrating audible cues for chat interactions.

Next Steps