Live iOS v1
Live iOS
Live
iOS
Version 1
Home
/
Live
/
iOS
/
SDK

Create a live event

Copy link

The first step is to configure the live event by providing a LiveEvent.CreateParams object. You can provide some basic information related to the event such as the title and the cover image that would show on the thumbnail. If not specified, the live event ID will show as the title and the thumbnail will show as black.

A live event requires a host for which you can provide candidates in the userIdsForHost property. Up to ten users can be set as host candidates and only one of them can act as a host for the event. When an incumbent host exits the event, any other candidates specified in userIdsForHost can enter the live event and act as a host.

Once you have configured the LiveEvent object, you can create a live event by calling the createLiveEvent() method. If the creation was successful, a liveEvent instance is returned, the status of the live event changes to created and a new open channel becomes available in which the host can chat.

In case the open channel isn't available, call fetchOpenChannel() to fetch the open channel.

func createLiveEvent() {
    let config = LiveEvent.CreateParams(
        userIdsForHost: [currentUser.userId],
        coverFile: coverImageURL,
        title: "New Event"
    )
    SendbirdLive.createLiveEvent(config: config) { result in
        switch result {
        case .success(let liveEvent):
            // A live event is successfully created.
        case .failure(let error):
            // Error occurred while creating a live event.
        }
    }
}