Quickstart
This quickstart shows how to use Cloudflare's core SDKs to add live video and audio to your iOS applications.
Objective
You'll learn how to:
- Install the RealtimeKit SDK
- Initialize the SDK
- Configure a RealtimeKit meeting
- Initialize the RealtimeKit meeting
- Go live with your RealtimeKit meeting
Before Getting Started
Make sure you've read the Getting Started with RealtimeKit topic and completed the following steps:
- Create a Developer Account
- Create a RealtimeKit Meeting
- Add Participant to the meeting
- Install Xcode
Step 1: Install the SDK
Add RealtimeKit
SDK through Swift Package Manager in Xcode. Use https://github.com/dyte-in/RealtimeKitCoreiOS.git as the package source.
Add the following entries to the info.plist file. This gives your app permissions to access the camera and microphone, access photos, and install the required fonts and icons.
<key>NSBluetoothPeripheralUsageDescription</key>
<string>We will use your Bluetooth to access your Bluetooth headphones.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>We will use your Bluetooth to access your Bluetooth headphones.</string>
<key>NSCameraUsageDescription</key>
<string>For people to see you during meetings, we need access to your camera.</string>
<key>NSMicrophoneUsageDescription</key>
<string>For people to hear you during meetings, we need access to your microphone.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>For people to share, we need access to your photos.</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
The UIBackgroundModes
key is used in the Info.plist
file of an iOS app to declare the app's supported background execution modes. This key is an array of strings that specifies the types of background tasks that the app supports. By declaring the background modes, the app can continue to run in the background and perform specific tasks even when it is not in the foreground.
It's important to note that the use of background modes should be justified and comply with Apple's App Store Review Guidelines. Apps that misuse background modes or unnecessarily run in the background may be rejected during the app review process.
Sources: Apple Developer Documentation: Declaring Your App's Supported Background Tasks
Step 2: Initialize the SDK
- The
RealtimeKitClient
is the main 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 DyteMobileClient, you should useRealtimeKitiOSClientBuilder().build()
.
let meeting = RealtimeKitiOSClientBuilder().build()
- Add the required listeners and implement callback stubs as per requirement
meeting.addMeetingRoomEventsListener(meetingRoomEventsListener: self)
meeting.addParticipantsEventListener(participantEventsListener: self)
meeting.addSelfEventsListener(selfEventsListener: self)
meeting.addChatEventsListener(chatEventsListener: self)
meeting.addPollEventsListener(pollEventsListener: self)
meeting.addRecordingEventsListener(recordingEventsListener: self)
meeting.addWaitlistEventListener(waitlistEventListener: self)
meeting.addLiveStreamEventsListener(liveStreamEventsListener: self)
Step 3: Configure a RealtimeKit meeting
Add authToken
that you got from the REST API to constructor of RtkMeetingInfo - Add Participant API
Name | Description |
---|---|
authToken | After you've created the meeting, add each participant to the meeting using the Add Participant API The API response contains the authToken . |
enableAudio | Set whether to join the meeting with your Mic ON or OFF by passing true or false . |
enableVideo | Set whether to join the meeting with your Camera ON or OFF by passing true or false . |
baseDomain | Base URL of the dyte's enviorment you have created the meeting on. |
let meetingInfo = RtkMeetingInfo(authToken: authToken,
enableAudio: true,
enableVideo: true)
Step 4: Initialize the RealtimeKit meeting
To initialize the connection request, call the doInit()
method obtained on
meeting
with the meetingInfo
argument. This will establish the connection
with the RealtimeKit meeting server.
meeting.doInit(meetingInfo: meetingInfo, onSuccess: {}, onFailure: {_ in})
To initialize the connection request, call the doInit
method
which is asynchronous and callback based.
Step 5: Go live with your RealtimeKit meeting!
Join the room
To join the meeting room, call joinRoom()
method on the meeting
instance as shown below.
meeting.joinRoom(onSuccess: {}, onFailure: {_ in})
Leave the room
Once the meeting is over, you can leave the meeting room. To leave the meeting
call leaveRoom()
on meeting
object.
meeting.leaveRoom(onSuccess: {}, onFailure: {_ in})