AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Goal | Manage audio playback for incoming/outgoing calls and messages |
| Import | import { CometChatSoundManager } from "@cometchat/chat-uikit-react-native"; |
| Play sound | CometChatSoundManager.play("incomingMessage") |
| Custom sound | CometChatSoundManager.play("outgoingMessage", "path/to/sound.mp3") |
| Pause sound | CometChatSoundManager.pause() |
| Sound events | incomingMessage, incomingMessageFromOther, outgoingMessage, incomingCall, outgoingCall |
| Default behavior | Plays 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 Key | When It Plays |
|---|---|
incomingMessage | New message received from current conversation |
incomingMessageFromOther | New message received from a different conversation |
outgoingMessage | Message sent |
incomingCall | Incoming call detected (loops) |
outgoingCall | Outgoing call initiated (loops) |
Methods
play
Plays the default or custom audio resource for a given sound event.| Parameter | Type | Description |
|---|---|---|
sound | string | Sound event key: "incomingMessage", "outgoingMessage", "incomingCall", "outgoingCall" |
customSound | string | Optional custom audio file path. Defaults to built-in sound. |
isRequire | boolean | Optional. Set to true if using require() for local assets. |
pause
Pauses the currently playing sound and resets playback position.Usage
Here is how to useCometChatSoundManager:
CometChatSoundManager, you can enhance the user experience in your chat application by integrating audible cues for chat interactions.