Quickstart
Before you start integrating Dyte into your application, make sure you've read the Getting Started with Dyte topic and completed the steps in the Integrate Dyte section.
The DyteClient is the root class of the SDK. It is the main entry point of the SDK. It is the only class that you need to instantiate in order to use the SDK.
To instantiate DyteClient, you can run the following command:
import React from 'react';
import { useDyteClient, DyteProvider } from '@dytesdk/react-native-core';
export default function App() {
const [meeting, initMeeting] = useDyteClient();
React.useEffect(() => {
const init = async () => {
const meetingOptions = {
audio: true,
video: true,
};
await initMeeting({
authToken: 'YourAuthToken',
defaults: meetingOptions,
});
};
init();
if (meeting) meeting.joinRoom();
}, []);
if (meeting)
return (
<DyteProvider value={meeting}>
{/* Render you Components here*/}
{/* Components rendered inside DyteProvider can access DyteClient object using useDyteClient() hook */}
</DyteProvider>
);
}
You can get the authToken using our backend APIs and then pass it to the init method of DyteClient.
Once join room process completes roomJoined
event is emitted on meeting.self
namespace. If you want to take any actions like enabling audio, video or start
and stop recording etc. it should be done after the roomJoined
event is fired.
For example:
meeting.self.on('roomJoined', () => {
console.log('User has joined the room', meeting.self.roomJoined);
// run my actions.
});
await meeting.joinRoom();
Leave room
Leave the meeting room.
await meeting.leaveRoom();