A notification is a short message that tells the user that something happened in the meeting. For example, a participant joined, a chat message arrived, or the network connection was lost. Some notifications also play a sound.
The UI Kit creates these notifications automatically. It listens for events from the Core SDK, creates a message for each event, and shows the message for a short time.
You can change the following:
- Which notifications the UI Kit shows
- How long each notification stays on the screen
- Which notifications play a sound
- Which audio file each sound uses
For the Core SDK event that each notification uses, refer to Core SDK notifications.
The UI Kit has two notification components:
| Component | Description |
|---|---|
RtkNotifications |
Listens for meeting events, shows the list of notifications, and plays the sounds. Most apps need only this component. |
RtkNotification |
Shows one notification. Use it only if you build your own notification list. |
| Component | Description |
|---|---|
rtk-notifications |
Listens for meeting events, shows the list of notifications, and plays the sounds. Most apps need only this component. |
rtk-notification |
Shows one notification. Use it only if you build your own notification list. |
On this page, "the notifications component" means the first component in this table.
The default meeting UI already includes the notifications component. You do not need to add anything.
If you build your own UI, add one notifications component inside the UI provider. Without this component, users do not see notifications and do not hear notification sounds.
<rtk-ui-provider id="rtk-ui-provider">
<!-- Your custom UI components -->
<rtk-notifications></rtk-notifications>
</rtk-ui-provider><RtkUiProvider meeting={meeting}>
{/* Your custom UI components */}
<RtkNotifications />
</RtkUiProvider>;<rtk-ui-provider [meeting]="meeting">
<!-- Your custom UI components -->
<rtk-notifications></rtk-notifications>
</rtk-ui-provider>The following table lists the notifications of the UI Kit and their default values. Use the setting key to change the settings of a notification. The duration is in milliseconds.
| Notification | Setting key | Shown | Plays a sound | Duration |
|---|---|---|---|---|
| A participant joined | participant_joined |
Yes | Yes | 2100 |
| A participant left | participant_left |
Yes | No | 2100 |
| A participant asks to join from the waiting room | participant_joined_waitlist |
Yes | Yes | 4000 |
| Another participant sent a text message | chat_new_message |
Yes | Yes | 2000 |
| Another participant edited a message | chat_message_edited |
No | No | 2000 |
| Another participant deleted a message | chat_message_deleted |
No | No | 2000 |
| Another participant created a poll | polls_new_poll |
Yes | Yes | 2000 |
| The meeting changed to a plugin | tab_sync_plugin_switched |
Yes | No | 2100 |
| The meeting changed to a participant's shared screen | tab_sync_screen_share_switched |
Yes | No | 2000 |
| The recording started | recording_started |
Yes | No | 2000 |
| The recording stopped | recording_stopped |
Yes | No | 2000 |
| A participant asked to join the stage | stage_requested_to_join |
No | No | 2000 |
| A participant joined the stage | stage_joined |
No | No | 2000 |
| The user's stage request was accepted | stage_request_accepted |
Yes | No | 3000 |
| The user's stage request was rejected | stage_request_rejected |
Yes | No | 3000 |
| New requests to join the stage are waiting | stage_new_request_received |
Yes | No | 3000 |
| The user invited a participant to the stage | stage_invite_sent |
Yes | No | 2000 |
| The speaker changed to another device | speaker_switched |
Yes | No | 5000 |
| The camera changed to another device | camera_switched |
Yes | No | 5000 |
| The microphone changed to another device | microphone_switched |
Yes | No | 5000 |
| The connection was lost and the meeting tries to reconnect | network_reconnecting |
Yes | No | 0 |
| Reconnecting takes a long time | network_delayed |
Yes | No | 0 |
| The meeting could not reconnect | network_disconnected |
Yes | No | 0 |
| The connection failed | network_failed |
Yes | No | 0 |
| The connection is back after a reconnect | network_restored |
Yes | No | 3000 |
| A recording or a livestream failed to start or stop, or a screen share failed to start | api_error |
Yes | No | 2000 |
Your app sent a notification with sendNotification() |
custom |
Yes | Yes | — |
For a notification that your app sends with sendNotification(), the UI Kit uses the duration and the sound that your app passes. Refer to Send your own notification.
Some notifications have a button. Some notifications appear only for some users:
participant_joined_waitlistandstage_requested_to_joinhave an Accept button. Only users who have permission to accept these requests see these notifications.- Only users who have permission to accept stage requests see
stage_new_request_received. network_disconnectedandnetwork_failedhave a button to end the meeting. If you hide these notifications, the user does not see this button.
The following rules apply to every notification:
- The screen shows a maximum of five notifications at one time. If the screen already shows five notifications, the UI Kit does not show a new notification. The UI Kit also does not show it later. But the UI Kit still plays the sound of the new notification. To change this limit, refer to Limit the notifications on the screen.
- The UI Kit does not show a notification if the browser tab is in the background.
- The UI Kit removes each notification when its duration ends. The user can also close a notification.
- When the user moves the pointer over the notifications, the timers pause.
- A notification with a duration of
0stays on the screen until the user closes it, or until another notification replaces it. The UI Kit uses this for network problems. - If a new notification has the same ID as an earlier notification, the new notification replaces the earlier one.
- After a notification sound starts, the UI Kit does not play another notification sound for three seconds.
- When a participant reconnects, the UI Kit does not show a join notification or a leave notification.
The UI Kit has a configuration object. This page calls it the UI config. The notification settings are in the config field of the UI config.
The following table lists the settings:
| Setting | Type | Description |
|---|---|---|
notifications |
object |
Shows or hides each notification. The values are true or false. |
notification_sounds |
object |
Turns the sound of each notification on or off. The values are true or false. |
notification_duration |
object |
Sets how long each notification stays on the screen, in milliseconds. |
notification_sound_urls |
object |
Sets the audio file that each notification plays. The values are URLs. |
participant_joined_sound_notification_limit |
number |
Stops the join, leave, and waiting room sounds when the meeting has more participants than this number. |
participant_chat_message_sound_notification_limit |
number |
Stops the chat and poll sounds when the meeting has more participants than this number. |
visible_notifications_limit |
number |
Sets the maximum number of notifications on the screen at one time. |
The first four settings are objects. All four objects use the same keys. These keys are the setting keys in the built-in notifications table.
Each of these four settings works separately. For example, if you hide a notification, the UI Kit still plays its sound. To stop the sound too, set the same key to false in notification_sounds.
If your UI config does not contain a setting or a key, the UI Kit uses the default value.
The UI config contains more than the notification settings. It also tells the UI Kit which components to show. Do not pass an object that contains only your notification settings. Such an object replaces the complete UI config, and the meeting UI does not work.
Always start with a complete UI config:
- Call
createDefaultConfig(). This function returns the default UI config. It contains every notification setting with its default value. - Change the values that you want to change.
- Pass the UI config to the
configproperty of the UI provider. If you use the default meeting UI, pass the UI config to theconfigproperty of the meeting component.
<rtk-ui-provider id="rtk-ui-provider">
<!-- Your custom UI components -->
<rtk-notifications></rtk-notifications>
</rtk-ui-provider>
<script type="module">
import { createDefaultConfig } from "https://cdn.jsdelivr.net/npm/@cloudflare/realtimekit-ui@latest/dist/esm/index.js";
const uiConfig = createDefaultConfig();
// Do not show a notification for new chat messages
uiConfig.config.notifications.chat_new_message = false;
// Do not play a sound when a participant joins
uiConfig.config.notification_sounds.participant_joined = false;
// Keep waiting room requests on the screen for 8 seconds
uiConfig.config.notification_duration.participant_joined_waitlist = 8000;
const provider = document.getElementById("rtk-ui-provider");
provider.config = uiConfig;
provider.meeting = meeting;
</script>import { useRealtimeKitMeeting } from "@cloudflare/realtimekit-react";
import {
RtkNotifications,
RtkUiProvider,
createDefaultConfig,
} from "@cloudflare/realtimekit-react-ui";
const uiConfig = createDefaultConfig();
// Do not show a notification for new chat messages
uiConfig.config.notifications.chat_new_message = false;
// Do not play a sound when a participant joins
uiConfig.config.notification_sounds.participant_joined = false;
// Keep waiting room requests on the screen for 8 seconds
uiConfig.config.notification_duration.participant_joined_waitlist = 8000;
export default function MyCustomUI() {
const { meeting } = useRealtimeKitMeeting();
return (
<RtkUiProvider meeting={meeting} config={uiConfig}>
{/* Your custom UI components */}
<RtkNotifications />
</RtkUiProvider>
);
}<rtk-ui-provider [meeting]="meeting" [config]="uiConfig">
<!-- Your custom UI components -->
<rtk-notifications></rtk-notifications>
</rtk-ui-provider>import { Component } from "@angular/core";
import type RealtimeKitClient from "@cloudflare/realtimekit";
import { createDefaultConfig } from "@cloudflare/realtimekit-angular-ui";
@Component({
selector: "app-custom-meeting",
templateUrl: "./custom-meeting.component.html",
})
export class CustomMeetingComponent {
meeting: RealtimeKitClient;
uiConfig = createDefaultConfig();
constructor() {
const settings = this.uiConfig.config;
// Do not show a notification for new chat messages
settings.notifications.chat_new_message = false;
// Do not play a sound when a participant joins
settings.notification_sounds.participant_joined = false;
// Keep waiting room requests on the screen for 8 seconds
settings.notification_duration.participant_joined_waitlist = 8000;
}
}The examples in the next sections use the same uiConfig object.
To read a default value in your code, use the object that createDefaultConfig() returns. For example, createDefaultConfig().config.notification_duration.participant_joined is 2100.
If you use UI Kit addons, the registerAddons function returns a complete UI config. This UI config also contains every notification setting with its default value. Do not create a second UI config with createDefaultConfig(). Change the settings in the UI config that registerAddons returns.
const uiConfig = registerAddons(addons, meeting);
uiConfig.config.notifications.chat_new_message = false;
document.getElementById("rtk-ui-provider").config = uiConfig;const uiConfig = registerAddons(addons, meeting);
uiConfig.config.notifications.chat_new_message = false;
// Pass uiConfig to the config prop of RtkUiProvider
setConfig(uiConfig);this.uiConfig = registerAddons(addons, this.meeting);
this.uiConfig.config.notifications.chat_new_message = false;In a large meeting, many notification sounds can disturb users. Two settings stop some sounds in large meetings. If the meeting has more participants than the limit, the UI Kit does not play these sounds. The UI Kit still shows the notifications.
The following table shows which sounds each setting controls:
| Setting | Default | Sounds that it controls |
|---|---|---|
participant_joined_sound_notification_limit |
3 |
participant_joined, participant_left, participant_joined_waitlist |
participant_chat_message_sound_notification_limit |
10 |
chat_new_message, chat_message_edited, chat_message_deleted, polls_new_poll |
Other sounds do not have a limit. To always play the sounds, in meetings of every size, set the limit to 0.
// Play join and leave sounds in meetings of up to 20 participants
uiConfig.config.participant_joined_sound_notification_limit = 20;
// Play chat and poll sounds in meetings of any size
uiConfig.config.participant_chat_message_sound_notification_limit = 0;The visible_notifications_limit setting is the maximum number of notifications on the screen at one time. The default is 5. To remove this limit, set it to 0.
// Show at most three notifications at one time
uiConfig.config.visible_notifications_limit = 3;This limit is not used for network_disconnected and network_failed. The UI Kit always shows these two notifications, because they have the button to end the meeting.
The notification_sound_urls setting contains the URL of the audio file for each notification. To use your own audio file for a notification, set the key of the notification to the URL of your file.
uiConfig.config.notification_sound_urls.participant_joined =
"https://example.com/sounds/join.mp3";
uiConfig.config.notification_sound_urls.chat_new_message =
"https://example.com/sounds/message.wav";The UI Kit accepts a URL only if both of the following are true:
- The URL is a complete URL that starts with
https://orhttp://. The UI Kit does not accept a relative path, such as/sounds/join.mp3. - The path of the URL ends with one of these file extensions:
.mp3,.wav,.ogg,.m4a,.aac,.flac,.opus, or.webm. The URL can have a query string after the file extension.
If the UI Kit does not accept a URL, it plays the default sound of that notification.
The UI Kit has two built-in sound files:
- Join sound: The default sound for
participant_joined,participant_left,stage_requested_to_join, andstage_joined. - Message sound: The default sound for all other notifications, except
custom.
The custom notification has no default sound.
The UI Kit plays a sound file only if the sound of the notification is turned on. For example, recording_started has a sound file, but its sound is turned off by default. To hear the sound, also set notification_sounds.recording_started to true.
In earlier versions of the UI Kit, one setting key controlled several notifications. These keys are deprecated. The UI Kit still reads these keys, so your existing configuration still works.
The following table lists the deprecated keys and the keys that replace them:
| Deprecated key | Replace with |
|---|---|
chat |
chat_new_message |
polls |
polls_new_poll |
tab_sync |
tab_sync_plugin_switched, tab_sync_screen_share_switched |
webinar |
stage_requested_to_join, stage_joined |
If your UI config contains a deprecated key, the UI Kit copies its value to the new keys. The values that you set for the new keys are lost. When you start to use the new keys, remove the deprecated key.
In notification_duration, the deprecated webinar key also changes tab_sync_screen_share_switched.
A user can turn off all notification sounds in the audio settings of the meeting. This changes the sounds for this user only. The UI Kit saves this choice in the browser, and uses it in later meetings too.
The UI Kit state contains this choice as prefs.muteNotificationSounds. If the value is true, the UI Kit does not play any notification sound. This is also true for the sounds that your settings turn on.
To read the UI Kit state in your app, refer to State Management.
Your app can show its own notifications in the same list as the built-in notifications. To do this, call the sendNotification function. The notifications component shows your notification.
<script type="module">
import { sendNotification } from "https://cdn.jsdelivr.net/npm/@cloudflare/realtimekit-ui@latest/dist/esm/index.js";
sendNotification(
{
id: "report-ready",
message: "Your report is ready",
duration: 3000,
},
"message",
);
</script>import { sendNotification } from "@cloudflare/realtimekit-react-ui";
sendNotification(
{
id: "report-ready",
message: "Your report is ready",
duration: 3000,
},
"message",
);import { sendNotification } from "@cloudflare/realtimekit-angular-ui";
sendNotification(
{
id: "report-ready",
message: "Your report is ready",
duration: 3000,
},
"message",
);sendNotification takes the following arguments:
| Argument | Required | Description |
|---|---|---|
notification |
Yes | The notification to show. |
playSound |
No | The sound to play with the notification. |
meeting |
No | The meeting that must show the notification. Use it when one page has more than one meeting. |
The following table lists the fields of the notification object:
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | The ID of the notification. Use a different ID for each notification. |
message |
string |
Yes | The text to show. |
duration |
number |
No | The time that the notification stays on the screen, in milliseconds. If you do not set it, the notification stays until the user closes it. |
icon |
string |
No | An icon to show before the text, as an SVG string. |
iconVariant |
string |
No | The color style of the icon. The default is primary. |
image |
string |
No | The URL of an image to show before the text. The UI Kit shows the image only if you do not set icon. |
button |
object |
No | A button to show after the text. It has a text, an onClick function, and an optional variant. |
The second argument, playSound, is the sound of the notification. Pass one of the following:
- The name of a built-in sound:
joined,left, ormessage. - The URL of your own audio file. The UI Kit accepts this URL with the same rules as the URLs in
notification_sound_urls.
sendNotification(
{ id: "hand-raised", message: "Ada raised a hand", duration: 3000 },
"https://example.com/sounds/hand.mp3",
);If you do not pass the second argument, the UI Kit plays the audio file from the custom key of notification_sound_urls. By default, this key is empty, so the notification has no sound. If the UI Kit does not accept the URL that you pass, the result is the same as no second argument.
The custom setting key controls all notifications that your app sends:
- To hide these notifications, set
notifications.customtofalse. - To turn off their sound, set
notification_sounds.customtofalse.
A page can have more than one meeting. In this case, each meeting has its own notifications component, and every notifications component shows your notification. To show the notification in one meeting only, pass that meeting as the third argument.
sendNotification(
{ id: "hand-raised", message: "Ada raised a hand", duration: 3000 },
"message",
meeting,
);Then only the notifications component of that meeting shows the notification and plays the sound.
If you want to control the position and the list of notifications in your own code, use the component that shows one notification. Set its notification property to a notification object. The object uses the notification fields.
This component does not remove itself from the page. When the duration ends, or when the user closes the notification, the component emits the rtkNotificationDismiss event. The event detail is the ID of the notification. When you receive this event, remove the component.
<rtk-notification id="my-notification"></rtk-notification>
<script>
const element = document.getElementById("my-notification");
element.notification = {
id: "report-ready",
message: "Your report is ready",
duration: 3000,
};
element.addEventListener("rtkNotificationDismiss", () => {
element.remove();
});
</script>import { useState } from "react";
import { RtkNotification } from "@cloudflare/realtimekit-react-ui";
const notification = {
id: "report-ready",
message: "Your report is ready",
duration: 3000,
};
function MyNotification() {
const [visible, setVisible] = useState(true);
if (!visible) return null;
return (
<RtkNotification
notification={notification}
onRtkNotificationDismiss={() => setVisible(false)}
/>
);
}<rtk-notification
*ngIf="visible"
[notification]="notification"
(rtkNotificationDismiss)="visible = false"
></rtk-notification>visible = true;
notification = {
id: "report-ready",
message: "Your report is ready",
duration: 3000,
};To pause the timer of a notification, set its paused property to true. To start the timer again, set paused to false.