Skip to main content
Version: 1.x.x

Join Meeting - React Native

note

This page uses the following asynchronous methods. Refer to their API reference for the errors each Promise may reject with, and handle these rejections appropriately based on your use case.

Overview

With our React Native SDK, you can choose to manually call the join() method or leave it up to the VideoSDK to automatically call the join() when the MeetingProvider is rendered.

caution

Use only one join mechanism. If you use join(), do not enable joinWithoutUserInteraction.

Do not call join() from a child component's mount effect. MeetingProvider configures the token in its own effect, which runs after child effects. Calling join() before the token is configured can result in 4002 INVALID_TOKEN, even when the token is valid.

Before joining the meeting, it has to be initialized. If you have not initialized a meeting yet, you can follow the guide here.

join()

  • To join a meeting you can call the join() method which is the part of the useMeeting hook of React SDK.
  • This method can be called after the meeting is initialized from the MeetingProvider.
caution

useMeeting hook mentioned above is accessible within the MeetingProvider only.

import { MeetingProvider, useMeeting } from "@videosdk.live/react-native-sdk";
import { TouchableOpacity, Text } from "react-native";

const App = () => {
//... Meeting Provider code
};

const MeetingView = () => {
//Getting the join method from hook and assigning event callbacks
const { join } = useMeeting();

const handleJoinMeeting = async () => {
// Joining Meeting
try {
await join();
} catch (err) {
console.error("join failed:", err);
}
};

return (
<>
<TouchableOpacity
onPress={() => {
handleJoinMeeting();
}}
>
<Text>Join Meeting</Text>
</TouchableOpacity>
</>
);
};

Events associated with Join

Following events are received when a participant successfully joins a meeting.

import { useMeeting } from "@videosdk.live/react-native-sdk";

const MeetingView = () => {
//Event to determine if the meeting has been joined
function onMeetingJoined() {
console.log("onMeetingJoined");
}

//Event to determine some other participant has joined
function onParticipantJoined(participant) {
console.log(" onParticipantJoined", participant);
}

//Getting the join method from the hook and assigning event callbacks
const { join } = useMeeting({
onMeetingJoined,
onParticipantJoined,
});

return <>...</>;
};

API Reference

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord