Join Live Stream - iOS
Once, the live stream is configured, the next step is to join it. With our iOS SDK, you can choose to manually call the join()
method. If you have not initialized the live stream yet, you can follow the guide here.
join()
- To join the meeting you can call the
join()
method ofMeeting
class. - This method can be called after the meeting is initialized using
VideoSDK
class.
Events associated with the join() method
Following events are received when a participant successfully joins the livestream.
- Local Participant will receive a
onMeetingJoined
event, when successfully joined. - Remote Participant will receive a
onParticipantJoined
event with the newly joinedParticipant
object from the event callback.
- Swift
func handleJoinStream(){
meeting?.join()
}
extension LiveStreamViewController: MeetingEventListener {
// Event to know meeting is joined
func onMeetingJoined() {
print("You just joined the livestream")
}
// Event to know some other participant joined
func onParticipantJoined(_ participant: Participant) {
print("A new remote participant", \(participant.displayName) + "just joined the livestream")
}
}
leave()
- To leave the live stream you can call the
leave()
method which is the part of theuseMeeting
hook of React SDK.
note
This method can be called only after the live stream is joined successfully.
Events associated with the leave() method
Following callbacks are received when a participant leaves the live stream.
- The Local Participant will receive the
onMeetingLeft
event, once they have successfully left the livestream. - All the Remote Participants—including all the hosts and audience members—will receive the
onParticipantLeft
event with theParticipant
object of the user who left the livestream.
- Swift
func handleLeaveStream(){
meeting?.leave()
}
extension LiveStreamViewController: MeetingEventListener {
func onMeetingLeft() {
// remove listeners
meeting?.localParticipant.removeEventListener(self)
meeting?.removeEventListener(self)
print("You left the livestream")
}
func onParticipantLeft(_ participant: Participant) {
// remove listener
participant.removeEventListener(self)
print(participant.displayName, "just left the livestream")
}
}
tip
You should call the leave()
method on the unmount of your main live stream component so that live stream is left once the view is unmounted.
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord