logo
On this page

Quick start

Prerequisites

​If you don't know how to create a project and obtain an app ID, please refer to this guide.

Prepare the environment

Before you attempt to integrate the SDK, make sure that the development environment meets the following requirements:

  • Xcode 15.0 or higher version.
  • iOS 12.0 or higher version and iOS devices that support audio and video.
  • The iOS device is connected to the Internet.

Integrate the SDK

Add dependencies

Do the following to add the ZegoUIKitPrebuiltLiveAudioRoom dependencies:

  • Open Terminal, navigate to your project's root directory, and run the following to create a podfile:

    Untitled
    pod init
    
    1
    Copied!
  • Edit the Podfile file to add the dependencies:

    Untitled
    pod 'ZegoUIKitPrebuiltLiveAudioRoom'
    
    1
    Copied!
  • In Terminal, run the following to install the required dependencies with Cocoapods:

    Untitled
    pod install
    
    1
    Copied!

Import SDKs

Run the following to import the SDKs: ZegoUIKitPrebuiltLiveAudioRoom and ZegoUIKit.

Untitled
import ZegoUIKitPrebuiltLiveAudioRoom
import ZegoUIKit
// YourViewController.swift
class ViewController: UIViewController {
    //Other code...
}
1
Copied!

Using the Live Audio Room Kit

  • Specify the userID and userName for connecting the Live Audio Room Kit service.
  • Create a roomID that represents the live audio room you want to create.
Note
  • userID, userName, and roomID can only contain numbers, letters, and underlines (_).
  • Using the same roomID will enter the same live audio room.
Warning

With the same roomID, only one user can enter the live audio room as host. Other users need to enter the live audio room as the audience.

Untitled
class ViewController: UIViewController {
    let appID: UInt32 = <#AppID#>
    let appSign: String = <#AppSign#>
    var userID: String = <#UserID#>
    var userName: String = <#UserName#>
    var roomID: String = <#RoomID#>
    
    @IBAction func startLiveAudio(_ sender: Any) {
        
        let config: ZegoUIKitPrebuiltLiveAudioRoomConfig = ZegoUIKitPrebuiltLiveAudioRoomConfig.host()
        let liveAudioVC: ZegoUIKitPrebuiltLiveAudioRoomVC = ZegoUIKitPrebuiltLiveAudioRoomVC(appID, appSign: appSign, userID: userID, userName: userName, roomID: roomID, config: config)
        liveAudioVC.modalPresentationStyle = .fullScreen
        self.present(liveAudioVC, animated: true, completion: nil)
    }

    @IBAction func joinLiveAudio(_ sender: Any) {
        let config: ZegoUIKitPrebuiltLiveAudioRoomConfig = ZegoUIKitPrebuiltLiveAudioRoomConfig.audience()
        let liveAudioVC: ZegoUIKitPrebuiltLiveAudioRoomVC = ZegoUIKitPrebuiltLiveAudioRoomVC(appID, appSign: appSign, userID: userID, userName: userName, roomID: roomID, config: config)
        liveAudioVC.modalPresentationStyle = .fullScreen
        self.present(liveAudioVC, animated: true)
    }
}
1
Copied!

Then, you can create a live audio room by presenting the VC.

Configure your project

  1. Open the Info.plist, and add the following code inside the dict part:
Untitled
<key>NSCameraUsageDescription</key>
<string>Access permission to camera is required.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Access permission to microphone is required.</string>
1
Copied!
  1. Disable the Bitcode. Select your target project, and follow the notes on the following two images to disable the Bitcode respectively.

Run & Test

Now you have finished all the steps!

You can simply click the Run in XCode to run and test your App on your device.

Custom prebuilt UI

Resources