Skip to main content
Version: 2.0.x

Initialise Meeting - iOS

To configure a VideoSDK meeting you require two things, first the token which will be used for Authentication purpose and a meetingId which will be used to specify where a participant will join. Let's see each of the steps closely.

Generating Token

You can generate a token in two ways:

  1. Temporary Token : You can visit Dashboard's API Key section and generate the temporary token from there.

  2. Server : You can setup JWT in backend and make an API call to get the token from your server.

To learn more about Authentication and token in detail you can follow this guide.

// Update server url here.
let LOCAL_SERVER_URL = "http://192.168.0.101:9000"

class APIService {

class func getToken(completion: @escaping (Result<String, Error>) -> Void) {
var url = URL("string: LOCAL_SERVER_URL")!
url = url.appendingPathComponent("get-token")

URLSession.shared.dataTask(with: url) { data, response, error in
if let data = data, let token = data.toJSON()["token"] as? String {
completion(.success(token))
} else if let err = error {
completion(.failure(err))
}
}
.resume()
}
}

Generating Meeting Id

With the token ready, we can get the meetingId from the VideoSDK's rooms API.

// Update server url here.
let LOCAL_SERVER_URL = "http://192.168.0.101:9000"

class APIService {

class func createMeeting(token: String, completion: @escaping (Result<String, Error>) -> Void) {
var url = URL(string: LOCAL_SERVER_URL)!
url = url.appendingPathComponent("create-meeting")

let params = ["token": token]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = try? JSONSerialization.data(withJSONObject: params, options: [])

URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let meetingId = data.toJSON()["meetingId"] as? String {
completion(.success(meetingId))
} else if let err = error {
completion(.failure(err))
}
}
.resume()
}
}

Initialization of Meeting

  1. To initialize the meeting, first we have to set the token of VideoSDK class. By using config() method, you can set the token property of VideoSDK class.
config
VideoSDK.config("<your token>");
  1. Now, we can initialize the meeting using a factory method provided by the SDK called initMeeting(). By passing the parameters according to the need, it will generate a new Meeting class and the initiated meeting will be returned.

initMeeting() is responsible for initializing the meeting with the provided configuration, which includes the meetingId, name, participantId and many more.

Let's take a deeper look at the available configuration options first.

initMeeting
    let meeting = VideoSDK.initMeeting(
meetingId: "abcd-efgh-hijk",
participantId: "JD", //optional
participantName: "John Doe",
micEnabled: true,
webcamEnabled: true,
customCameraVideoStream: customVideoStream, //optional
customAudioTrack: customAudioStream, //optional
mode: .CONFERENCE, //optional (default mode is conference)
)
  • meetingId :

    • meetingId is unique identifiers that allow participants to join a specific meeting or room.
    • It will accept String type value.
    • It will be in the format of xxx-yyy-zzz and will be generated using the VideoSDK's Room API.
  • participantId:

    • This will be the unique identifier for the participant inside the meeting.
    • It can be used to specify the unique identifier which can be linked with your own database service.
    • It has to be of String type.
    • If you passed null then by default VideoSDK will generate unique id for each participant.
caution

You must ensure that the participantId is not repeated in the same meeting or room, It will enable VideoSDK to eliminate any participant respect to that participantId.

  • name:

    • This will represent the name of the participant in the meeting.
    • It will accept String type value.
  • micEnabled:

    • This is a boolean flag, indicating whether a participant's microphone will be automatically enabled when they join a meeting.
  • webcamEnabled:

    • This is a boolean flag, indicating whether a participant's webcam will be automatically enabled when they join a meeting.

    customCameraVideoStream:

    • If you want to set the initial video custom track, then you can pass the customVideoTrack created using createCameraVideoTrack method of VideoSDK class.

    • It has to be of CustomRTCMediaStream type.

  • customAudioTrack:

    • If you want to set the initial audio custom track, then you can pass the customAudioTrack created using createAudioTrack method of VideoSDK class.

    • It has to be of CustomRTCMediaStream type.

  • mode:

    • There are 2 types of modes:

      1. CONFERENCE : Both audio and video streams will be produced and consumed in this mode.

      2. VIEWER : Audio and video streams will not be produced or consumed in this mode.

    • It has to be of String type.

    • If you passed null then by default VideoSDK will set CONFERENCE mode.

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