logo
On this page

Set a leave confirmation dialog


Video Conference Kit (ZegoUIKitPrebuiltVideoConference) leaves a conference by default when the user clicks the Leave button.

If you want to add a confirmation dialog box to double confirm whether the user wants to leave a conference, you can use the leaveConfirmDialogInfo config. After configuring this parameter, a confirmation dialog box with the default style will pop up before leaving or ending the conference, showing the confirmation info you set.

The effect will be like this:

Here is the reference code:

Untitled
class ViewController: UIViewController {
    
    let selfUserID: String = "userID";
    let selfUserName: String = "userName";
    let yourAppID: UInt32 = YourAppID;
    let yourAppSign: String = YourAppSign;
    let conferenceID : String = "testConferenceID"
    
    @IBOutlet weak var userIDLabel: UILabel! {
        didSet {
            userIDLabel.text = selfUserID
        }
    }
    @IBOutlet weak var userNameLabel: UILabel! {
        didSet {
            selfUserName = String(format: "zego_%@", selfUserID)
            userNameLabel.text = selfUserName
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    @IBAction func videoConference(_ sender: Any) {
        
        // Modify your custom configurations here.
        let config: ZegoUIkitPrebuiltVideoConferenceConfig = ZegoUIkitPrebuiltVideoConferenceConfig()
        let leaveConfirmDialogInfo = ZegoLeaveConfirmDialogInfo();
        leaveConfirmDialogInfo.title = "Leave the conference";
        leaveConfirmDialogInfo.message = "Are you sure to leave the conference?";
        leaveConfirmDialogInfo.cancelButtonName = "Cancel";
        leaveConfirmDialogInfo.confirmButtonName = "Confirm";
        config.leaveConfirmDialogInfo = leaveConfirmDialogInfo;
        
        let videoConferenceVC = ZegoUIKitPrebuiltVideoConferenceVC.init(yourAppID, appSign: yourAppSign, userID: selfUserID, userName: self.selfUserName ?? "", conferenceID: conferenceID, config: config)
        videoConferenceVC.modalPresentationStyle = .fullScreen
        self.present(videoConferenceVC, animated: true, completion: nil)
    }
}
1
Copied!

If you want to listen for leave events, for example, to save the conference recording when leaving the conference, ZegoUIKitPrebuiltVideoConference provides an onLeave callback that will be triggered when the conference ends. And sure, you can also implement custom business logic in the onLeave.

Previous

Customize the menu bar

Next

Turn off cam and mic when joining meeting

On this page

Back to top