Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

FieldValue
ClassCometChatSoundManager
Package@cometchat/chat-uikit-react
Sound typesincomingMessage, outgoingMessage, incomingMessageFromOther, incomingCall, outgoingCall
Custom soundsPass URL as second argument: CometChatSoundManager.play('incomingMessage', '/my-sound.mp3')
DisableUse disableSoundForMessages / disableSoundForCalls in config prop

Overview

CometChatSoundManager handles audio notifications for chat events. It plays sounds when messages are sent/received and when calls are initiated/received. Components use it internally — you don’t need to call it manually unless you want custom behavior.

Sound Types

TypeWhen it playsLoops
outgoingMessageUser sends a messageNo
incomingMessageMessage received in the active conversationNo
incomingMessageFromOtherMessage received in a different conversationNo
incomingCallIncoming call notificationYes
outgoingCallOutgoing call ringingYes

Disabling Sounds

Use the config prop on CometChatProvider:
<CometChatProvider
  appId="YOUR_APP_ID"
  region="us"
  authKey="YOUR_AUTH_KEY"
  uid="cometchat-uid-1"
  config={{
    disableSoundForMessages: true,
    disableSoundForCalls: true,
  }}
>
  <MyChatApp />
</CometChatProvider>
You can also disable sounds per-component via props like disableSoundForMessages on CometChatConversations and CometChatMessageComposer.

Custom Sound URLs

Replace default sounds with your own audio files:
import { CometChatSoundManager } from "@cometchat/chat-uikit-react";

// Play a custom notification sound
CometChatSoundManager.play("incomingMessage", "/sounds/notification.mp3");

// Or use convenience methods
CometChatSoundManager.onIncomingMessage("/sounds/notification.mp3");
CometChatSoundManager.onOutgoingMessage("/sounds/sent.mp3");

API Reference

Static Methods

MethodSignatureDescription
play(sound: SoundType, customUrl?: string) => voidPlay a sound (with optional custom URL)
pause() => voidStop the currently playing sound
onOutgoingMessage(customUrl?: string) => voidPlay outgoing message sound
onIncomingMessage(customUrl?: string) => voidPlay incoming message sound
onIncomingOtherMessage(customUrl?: string) => voidPlay incoming message from other conversation
onIncomingCall(customUrl?: string) => voidPlay incoming call sound (loops)
onOutgoingCall(customUrl?: string) => voidPlay outgoing call sound (loops)

Browser Autoplay Policy

Browsers require user interaction before playing audio. CometChatSoundManager checks navigator.userActivation before attempting playback. If the user hasn’t interacted with the page yet, sounds are silently skipped.

SSR Safety

All Audio API usage is guarded behind typeof Audio !== 'undefined' checks. The sound manager is safe to import in server-side rendering environments — it simply no-ops when Audio is unavailable.