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.
The Core SDK does not show notifications. It also has no notification API. Instead, the SDK emits an event when something happens. Your app listens for the events that it needs. Then your app decides how to show them, for example as a toast message, a badge, or a sound.
This page lists the events that the UI Kit uses for its notifications. You can use the same events for your notifications.
If you use the UI Kit, you do not need to listen for these events yourself. Refer to UI Kit notifications.
To create a notification, your app does the same three things for every event:
- Listen for the event on the correct part of the meeting object.
- Read the event data, and decide whether to tell the user.
- Show the notification in your UI.
The following example shows a notification when a participant joins:
import { useEffect } from "react";
import { useRealtimeKitMeeting } from "@cloudflare/realtimekit-react";
function JoinNotifications() {
const { meeting } = useRealtimeKitMeeting();
useEffect(() => {
if (!meeting) return;
const onParticipantJoined = (participant) => {
// Replace this line with your own notification UI
console.log(`${participant.name} joined`);
};
meeting.participants.joined.on("participantJoined", onParticipantJoined);
return () => {
meeting.participants.joined.off("participantJoined", onParticipantJoined);
};
}, [meeting]);
return null;
}const onParticipantJoined = (participant) => {
// Replace this line with your own notification UI
console.log(`${participant.name} joined`);
};
meeting.participants.joined.on("participantJoined", onParticipantJoined);
// Remove the listener when you no longer need it
meeting.participants.joined.off("participantJoined", onParticipantJoined);All events on this page work in the same way. Only the object, the event name, and the event data are different.
The following sections group the events by topic. Each table shows what happened, which object emits the event, the event name, and the event data.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| A participant joined the meeting | meeting.participants.joined |
participantJoined |
The participant who joined |
| A participant left the meeting | meeting.participants.joined |
participantLeft |
The participant who left |
| A participant entered the waiting room | meeting.participants.waitlisted |
participantJoined |
The participant who is waiting |
| A participant is not in the waiting room anymore | meeting.participants.waitlisted |
participantLeft |
The participant |
For more information, refer to Remote participant events and Waiting Room.
When a participant loses the connection and reconnects, the participant can get a new peer ID. Then your app can receive participantJoined for the new peer ID and participantLeft for the old peer ID. But the participant did not really leave the meeting.
To skip the notifications for these participants, check the following properties:
| Property | Where to read it | What it means |
|---|---|---|
participant.peerIdBeforeReconnect |
The participant in the participantJoined event |
The participant reconnected. The value is the old peer ID of the participant. |
participant.replacedByPeerId |
The participant in the participantLeft event |
The participant reconnected. The value is the new peer ID of the participant. |
meeting.participants.joined.on("participantJoined", (participant) => {
// The participant reconnected. They did not join again.
if (participant.peerIdBeforeReconnect) return;
console.log(`${participant.name} joined`);
});
meeting.participants.joined.on("participantLeft", (participant) => {
// The participant reconnected. They did not leave.
if (participant.replacedByPeerId) return;
console.log(`${participant.name} left`);
});| What happened | Listen on | Event | Event data |
|---|---|---|---|
| A chat message changed | meeting.chat |
chatUpdate |
action, which is add, edit, or delete, and message |
| A poll was created or updated | meeting.polls |
pollsUpdate |
polls, the list of polls, and newPoll, which is true for a new poll |
Keep the following in mind:
- The SDK also emits
chatUpdatewhen a user edits or deletes a message. To show a notification for new messages only, check thatactionisadd. - The SDK also emits both events for the actions of the local user. To skip these events, compare the user ID in the message or the poll with
meeting.self.userId. - To show a notification for new polls only, check that
newPollistrue. The new poll is the last item inpolls.
For more information, refer to Receiving Chat Messages and Get Notified When a Poll is Created or Updated.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| The active microphone, camera, or speaker changed | meeting.self |
deviceUpdate |
device, the new device |
To find out which device changed, read device.kind. The value is audioinput for a microphone, videoinput for a camera, and audiooutput for a speaker.
For more information, refer to Device update.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| The state of the connection to the meeting changed | meeting.meta |
socketConnectionUpdate |
state, reconnectionAttempt, and reconnected |
The following table explains each value of state:
state |
What it means |
|---|---|
connected |
The connection works. If reconnected is true, the connection was lost before and is now restored. |
disconnected |
The connection is lost. The SDK starts to reconnect. |
reconnecting |
The SDK is trying to reconnect. reconnectionAttempt is the number of the current attempt. |
failed |
The SDK could not reconnect. |
For more information, refer to Socket connection updates.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| The state of the recording changed | meeting.recording |
recordingUpdate |
The new recording state |
The state is RECORDING after the recording starts. The state is STOPPING when the recording is stopping.
These events apply to meetings that use a stage, such as webinars.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| A remote participant's stage status changed | meeting.participants.joined |
stageStatusUpdate |
The participant |
| The local user's stage status changed | meeting.stage |
stageStatusUpdate |
The new stage status |
| The number of pending stage requests changed | meeting.stage |
newStageRequest |
count, the number of pending requests |
| A host approved the local user's stage request | meeting.stage |
stageRequestApproved |
None |
| A host rejected the local user's stage request | meeting.stage |
stageRequestRejected |
None |
For a remote participant, read participant.stageStatus. The value is REQUESTED_TO_JOIN_STAGE when the participant asks to join the stage. The value is ON_STAGE when the participant is on the stage.
Show a notification for newStageRequest only to users who can accept stage requests. To check this, read meeting.self.permissions.acceptStageRequests.
For more information, refer to Stage Management events.
| What happened | Listen on | Event | Event data |
|---|---|---|---|
| The plugin or shared screen that all participants see changed | meeting.meta |
activeTabUpdate |
type, which is plugin or screenshare, and id |
To show a name in your notification, use id. For a plugin, find the plugin with this ID in meeting.plugins.active. For a shared screen, find the participant with this ID in meeting.participants.joined.